简体   繁体   English

在 gitlab CI/CD 中使用 devtoolset

[英]Using devtoolset in gitlab CI/CD

I have created a CentOS 7 image with the relevant packages needed to run a CI/CD pipeline on gitlab.com.我已经创建了一个 CentOS 7 映像,其中包含在 gitlab.com 上运行 CI/CD 管道所需的相关包。 One of the requirements is to use gcc 8. I am using devtoolset-8 for that.要求之一是使用 gcc 8。我为此使用了 devtoolset-8。 The image is stored on dockerhub.图像存储在 dockerhub 上。 I have added the following to /etc/profile:我已将以下内容添加到 /etc/profile:

source /opt/rh/devtoolset-8/enable

If I pull this image manually and run this in docker, it is all as expected:如果我手动拉取此映像并在 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

However, when I use the image in a CI/CD pipeline on gitlab.com itt looks like devtoolset is not enabled.但是,当我在 gitlab.com 上的 CI/CD 管道中使用该图像时,似乎未启用 devtoolset。 I also tried to manually do this inside the script: section.我还尝试在 script: 部分中手动执行此操作。 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?关于问题可能是什么的任何想法?

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. ...如果你想使用 cmake 来构建一些东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM