1

我创建了一个 CentOS 7 映像,其中包含在 gitlab.com 上运行 CI/CD 管道所需的相关软件包。要求之一是使用 gcc 8。为此,我正在使用 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。我还尝试在脚本中手动执行此操作:部分。作业输出:

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

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

4

1 回答 1

2

我今天遇到了这个问题。

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

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

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

于 2021-03-03T21:32:37.480 回答