我正在编写Jenkins文件来为多分支管道和docker / docker管道插件创建构建,以便在Jenkins中启动docker容器。我有一个图像,我想用它来构建docker容器。我需要从某个URL中提取此图像:docker.abc.com
,运行容器,然后在容器内执行所有Jenkins内容。我目前收到以下错误:
Jenkins does not seem to be running inside a container
我的代码看起来像这样:
node {
try {
// set working directory
dir(working directory here){
stage(main){
checkout scm
docker.image("docker.abc.com/def:latest").inside{
// do Jenkins stuff
}
}
}
}
catch {
// catch error and send notification
}
}
答案 0 :(得分:0)
几天前我解决了这个问题。我的代码结构(我无法分享确切的代码,抱歉):
node {
try {
// set working directory
dir(working directory here){
stage(main){
// get docker image
// defined a docker command here that runs the container, clones git repository inside it and uses makefile to build the project
// ran the docker command in a shell script
}
}
}
catch {
// catch error and send notification
}
}