Using devtoolset in gitlab CI/CD

912 views Asked by At

I have created a CentOS 7 image with the relevant packages needed to run a CI/CD pipeline on gitlab.com. One of the requirements is to use gcc 8. I am using devtoolset-8 for that. The image is stored on dockerhub. I have added the following to /etc/profile:

source /opt/rh/devtoolset-8/enable

If I pull this image manually and run this in docker, it is all as expected:

root@xxxxxx~]# docker run -i -t yyyyyy/zzzz:latest
...
[root@3463ccd63d42 build]# cmake -DCMAKE_BUILD_TYPE=Debug ..
-- The C compiler identification is GNU 8.3.1
-- The CXX compiler identification is GNU 8.3.1

However, when I use the image in a CI/CD pipeline on gitlab.com itt looks like devtoolset is not enabled. I also tried to manually do this inside the script: section. The job output:

Pulling docker image yyyyyy/zzzz:latest
...
Executing "step_script" stage of the job script
$ scl enable devtoolset-8 bash
..
$ cmake -DCMAKE_BUILD_TYPE=Debug ..
-- The C compiler identification is GNU 4.8.5

Any ideas on what the problem might be?

1

There are 1 answers

0
p m On

I have ran into this very problem today.

I am not sure what the mechanics behind this problem are, but the solution would be to use, for example:

scl enable devtoolset-8 'cmake .. && make all'

...if you would like to use cmake to build something.