我设置管道来构建我的基于wildfly-swarm的微服务构建docker镜像并将其推送到docker存储库。所以我设置了管道脚本并执行了构建和日志(附件下面)我们看到构建成功但我在阶段视图中失败状态,错误:"脚本返回退出代码1"。
失败的剧本是:
docker build -f Dockerfile -t swarm-microservice .
如果我从以下位置更改脚本执行并不重要:
sh '''docker build -f Dockerfile -t swarm-microservice .'''
为:
script {
docker.build("swarm-microservice", '.')
}
我还尝试通过将脚本更改为:
来更改脚本结果的输出sh '''docker build -f Dockerfile -t swarm-microservice . || true '''
但它没有帮助。我错过了什么?
Started by user test
[Pipeline] node
Running on node-lin02 in /build/workspace/XYZ/some-docker-image
[Pipeline] copyArtifacts
Copied 2 artifacts from "XYZ » swarm-microservice" build number 49
Copied 0 artifacts from "XYZ » swarm-microservice » XYZ-swarm-microservice" build number 49
[some-docker-image] Running shell script
[some-docker-image] Running shell script
+ docker build -f Dockerfile -t swarm-microservice .
Sending build context to Docker daemon 380.9MB
Step 1/4 : FROM openjdk:8u151-jdk-slim
---> 22f79f57057d
Step 2/4 : ADD swarm-microservice-swarm.jar /opt/swarm-microservice-swarm.jar
---> Using cache
---> 16f16f07a4da
Step 3/4 : EXPOSE 8281
---> Using cache
---> 26820815d1d1
Step 4/4 : ENTRYPOINT java -jar -Djava.net.preferIPv4Stack=true -XX:MaxRAM=512m /opt/swarm-microservice-swarm.jar -S src
---> Using cache
---> 41c896987ba6
Successfully built 41c896987ba6
Successfully tagged swarm-microservice:latest
[Pipeline] sh
[some-docker-image] Running shell script
+ set -e
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (tag docker image)
[Pipeline] sh
[some-docker-image] Running shell script
+ docker tag swarm-microservice my.awesome.demo.so.test.repo.com:5000/XYZ/swarm-microservice
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (push docker image to repository)
[Pipeline] sh
[some-docker-image] Running shell script
+ docker push my.awesome.demo.so.test.repo.com:5000/XYZ/swarm-microservice
The push refers to a repository [my.awesome.demo.so.test.repo.com:5000/XYZ/swarm-microservice]
2e35fec0db40: Preparing
c09cee929b6f: Preparing
5f09fc66f922: Waiting
cec7521cdf36: Waiting
2e35fec0db40: Layer already exists
063e7100cc44: Layer already exists
latest: digest: sha256:xxx size: 1788
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS