使用Dockerfile插件构建容器

时间:2020-10-12 22:34:00

标签: docker jenkins jenkins-pipeline

在本文Build Containers之后,我尝试在Jenkinsfile上执行此代码,令我惊讶的是,我不相信它会起作用,但是最后,我的容器停止了移动工作……

[Pipeline] withDockerContainer
Jenkins seems to be running inside container 10f1790a9e048db8a874bede30946a607fb5c0ea4c060f177da12c9fe1328d43
$ docker run -t -d -u 0:0 -w /var/jenkins_home/workspace/mobile --volumes-from 10f1790a9e048db8a874bede30946a607fb5c0ea4c060f177da12c9fe1328d43 -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** my-image:6 cat
$ docker top 0bf03e000c2832cc06a270360c8744308ed81d43f36fd297ee286df5dbb3cb4b -eo pid,comm
[Pipeline] {
[Pipeline] sh
+ make test
make: *** No rule to make target 'test'.  Stop.
[Pipeline] }
$ docker stop --time=1 0bf03e000c2832cc06a270360c8744308ed81d43f36fd297ee286df5dbb3cb4b
$ docker rm -f 0bf03e000c2832cc06a270360c8744308ed81d43f36fd297ee286df5dbb3cb4b
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 2
Finished: FAILURE

如何使容器保持使用管道运行(我迷路了)。有什么建议吗?

node {
    checkout scm

    def customImage = docker.build("my-image:${env.BUILD_ID}")

    customImage.inside {
        sh 'make test'
    }
}

0 个答案:

没有答案