Jenkins Docker管道退出代码-1 [英] Jenkins Docker Pipeline Exit Code -1

查看:937
本文介绍了Jenkins Docker管道退出代码-1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个Jenkinsfile,它使用docker插件在给定容器内运行脚本.这对于某些图像可以正常工作,但在其他图像上立即返回-1退出代码将失败.我们已将错误减少为简单的sleep.这是Jenkinsfile:

We have a Jenkinsfile that uses the docker plugin to run a script inside a given container. This works fine for some images, but fails immediately with a -1 exit code on others. We've reduced the error down to a simple sleep. This is the Jenkinsfile:

node("docker") {
    def wheezy_image = docker.image("pyca/cryptography-runner-wheezy")
    wheezy_image.pull()
    wheezy_image.inside {
        sh """sleep 120"""
    }
}

这是詹金斯的输出

+ docker pull pyca/cryptography-runner-wheezy
Using default tag: latest
latest: Pulling from pyca/cryptography-runner-wheezy
Digest: sha256:ff5d9f661b05d831ace3811eec9f034fed7994279ff2307695a2cb7c32d6fa11
Status: Image is up to date for pyca/cryptography-runner-wheezy:latest
[Pipeline] sh
[3525-VE2ETALXLYB7VN3] Running shell script
+ docker inspect -f . pyca/cryptography-runner-wheezy
.
[Pipeline] withDockerContainer
$ docker run -t -d -u 1000:1000 -w /var/jenkins_home/workspace/3525-VE2ETALXLYB7VN3 --volumes-from 1382a2e208dd5575acd26f11678855282fc854319096de60cef6818ea279f25f -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 ******** -e ******** -e ******** -e ******** --entrypoint cat pyca/cryptography-runner-wheezy
[Pipeline] {
[Pipeline] sh
[3525-VE2ETALXLYB7VN3] Running shell script
+ sleep 120
[Pipeline] }
$ docker stop --time=1 887db8989e03a10dd89132b1ac6e18261ee4a49e6afe8b0c5568326b6c023654
$ docker rm -f 887db8989e03a10dd89132b1ac6e18261ee4a49e6afe8b0c5568326b6c023654
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline

GitHub has been notified of this commit’s build result

ERROR: script returned exit code -1
Finished: FAILURE

有趣的是,如果睡眠时间少于1秒,那么这会过去(但是120秒睡眠在其他许多图像上都可以正常工作).

Interestingly, if the sleep is less than 1 second then this passes (but the 120 second sleep works just fine on many of the other images).

作为参考,这是一个有效的 jessie图片,和乳清图像不会.

For reference, here is a jessie image that works, and a wheezy image that does not.

有人知道这里可能发生什么事吗?

Does anyone know what might be going on here?

推荐答案

似乎与未安装ps的映像有关.我只是以debian为基础,并且能够复制它不起作用.安装了ps,它确实起作用了.您也可以使用withRun函数,它可以正常工作.这是我的Jenkinsfile:

Looks to be related to your image not having ps installed. I just took the debian base and was able to replicate that it wouldn't work. Installed ps, and it did work. You can also use the withRun function and it works. Here's my Jenkinsfile:

node("docker") {

    // Weezy that also ran... apt-get update && apt-get install -y procps
    def wheezy_image = docker.image("smalone/weezy-ps-test")
    wheezy_image.pull()
    wheezy_image.inside {
       sh 'sleep 2'
    }

      // Base image for weezy-ps-test that has no ps installed using withRun() instead of inside()
    wheezy_image = docker.image("debian:wheezy")
    wheezy_image.pull()
    wheezy_image.withRun { c ->
       sh 'sleep 2'
    }

    // Base image for weezy-ps-test that has no ps installed
    wheezy_image = docker.image("debian:wheezy")
    wheezy_image.pull()
    wheezy_image.inside {
       sh 'sleep 2'
    }
}

如果不存在,我将在docker管道插件上打开一张票.

I'll open a ticket on the docker pipeline plugin, if one doesn't exist.

开了张罚单,但他们还没有找到根本原因.请参阅: https://issues.jenkins-ci.org/browse/JENKINS-40101跟踪此问题的状态!

There was a ticket open, but they hadn't found the root cause yet. See: https://issues.jenkins-ci.org/browse/JENKINS-40101 to track the status of this issue!

这篇关于Jenkins Docker管道退出代码-1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆