Problem running my build job on self-managed gitlab

Replace this template with your information

I created a simple gitlab ci file in my project.
The pipeline does not work and I have this error:

On line 17 (before the error) the pipeline is trying to use a script that I have not included.


Here is my .gitlab-ci.yml content:

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.

Here is the full screenshot:

Thanks in advance for your help.

Process exited with status 1 can be anything

Can you please post the entire job log output ?

Thanks for your reply, I just added the full screenshot of log output.

Thank you for the screenshots.

When you job runs it finds no apt-get which means the runner is installed in non debian/ubuntu based distribution.

So this seems like a runner problem.

Where does your runner live? How did you setup it ?

EDIT:
You runner uses the SSH executor which means it SSHs into a machine and runs the job commands.

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.

1 Like

Thank you very much for the explanation!
I added the command and here is the result:

cat /etc/os-release && exit 0
33 NAME="Red Hat Enterprise Linux Server"
34 VERSION="7.6 (Maipo)"
35 ID="rhel"
36 ID_LIKE="fedora"
37 VARIANT="Server"
38 VARIANT_ID="server"
39 VERSION_ID="7.6"
40 PRETTY_NAME="Red Hat Enterprise Linux Server 7.6 (Maipo)"
41 ANSI_COLOR="0;31"
42 CPE_NAME="cpe:/o:redhat:enterprise_linux:7.6:GA:server"
43 HOME_URL="https://www.redhat.com/"
44 BUG_REPORT_URL="https://bugzilla.redhat.com/"
45 REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 7"
46 REDHAT_BUGZILLA_PRODUCT_VERSION=7.6
47 REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
48 REDHAT_SUPPORT_PRODUCT_VERSION="7.6"

So I will try “yum” as you said and let you know.

1 Like

Yeah Yum will do the job :ok_hand:

Glad the problem is solved! Great job!

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?

1 Like

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.