Jenkins Docker Pipeline Exit Code -1

后端 未结 1 950
再見小時候
再見小時候 2021-02-07 06:45

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.

相关标签:
1条回答
  • 2021-02-07 07:00

    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'
        }
    }
    

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

    EDIT: 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!

    0 讨论(0)
提交回复
热议问题