0

我正在编写一个 Jenkinsfile 来为多分支管道和 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
    }
}
4

1 回答 1

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
    }
}
于 2017-10-06T18:43:05.410 回答