stages: # List of stages for jobs, and their order of execution
- build
- test
build-job: # This job runs in the build stage, which runs first.
stage: build
image: php:7.4-fpm
script:
- echo "Php version :"
- php -v
before_script:
- apt-get update -yqq
- apt-get install -yqq git libmcrypt-dev libpq-dev libcurl4-gnutls-dev libicu-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev
# Install PHP extensions
#- docker-php-ext-install mbstring curl json gd xml zip
- docker-php-ext-install gd
# Install and run Composer
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install
unit-test-job: # This job runs in the test stage.
stage: test # It only starts when the job in the build stage completes successfully.
script:
- echo "Running unit tests... This will take about 60 seconds."
- sleep 60
- echo "Code coverage is 90%"
Just to mention that I tried the same gitlab ci file on Gitlab.com and it works well.
Yes but I can’t figure out how to change runner, It’s my company gitlab and I think it’s using Shared runners, here is the list of runners when I check CI/CD settings:
Here I see that you have 4 runners: I suppose 2 are for CI (and maybe they both use SSH executor) and another 2 for something else (Maybe for deployment) and I think they use kubernetes executor (Because of the openshift tag).
To change the runner your jobs run on you should tag you jobs with one of the tags on the runner you want to use like this:
build-job:
## To select gitlab-runner-1-runner-5cd...
tags:
- openshift-dev-stable
Make sure you ask your system admin (or the one who setup the runners) about each runner, and whether it is okey for you to run your jobs on them.
Otherwise, you can still use you the same runner gitlab-runner-IC-01, but you should adapt you gitlab-ci.yml file to the runners host OS.
To do so, add a step in your before_script to check the linux distribution your job is using like this. Then use the appropriate tools.
before_script:
- cat /etc/os-release && exit 0
This command should give your os distro and version. What does it give you ?
EDIT:
In case cat /etc/os-release && exit 0 returned Centos, Redhat linux, Oracle linux, Amazon linux or any other Redhat based distros you should use yum instead of apt-get.
You can google the names for the packages you need to install to find out their package names in the Distro you are using.
It does not really solve the problem, I had some permission errors with yum, but I think it’s related to the runner (as always), I sent an email to the admin and I hope I will get an answer about changing the runner or some sort of solution for that.
Do you have an idea why the runner is executing this script?
Which script ? Can you share with the output for the yum errors ?
Not sure, but I think that the problem is related to the runner. It may be running as a user who does not have root access (not a sudoer). So your admin should add the user to the sudoers and reexecute the commands with sudo.
Otherwise, the best solution is to change the runner executor to something like docker or docker-machine. Since the SSH executor is not so the best nor the easiest to work with. Quoting the docs:
The SSH executor is added for completeness, but it’s the least supported among all executors.