在gitlab CI / CD

问题描述

我用在gitlab.com上运行CI / CD管道所需的相关软件包创建了CentOS 7映像。要求之一是使用gcc8。为此,我正在使用devtoolset-8。图像存储在dockerhub上。我已将以下内容添加到/ etc / profile:

source /opt/rh/devtoolset-8/enable

如果我手动拉出该图像并在docker中运行,则一切都如预期:

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

但是,当我在gitlab.com上的CI / CD管道中使用映像时,似乎未启用devtoolset。我还尝试在script:部分中手动执行此操作。作业输出

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

关于可能是什么问题的任何想法?

解决方法

我今天遇到了这个问题。

我不确定这个问题背后的机制是什么,但解决方案是使用,例如:

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

...如果你想使用 cmake 来构建一些东西。