Jenkins Docker Pipeline Exit Code -1

16,467

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!

Share:
16,467

Related videos on Youtube

Paul Kehrer
Author by

Paul Kehrer

I work on https://cryptography.io and other Python Cryptographic Authority projects.

Updated on September 27, 2022

Comments

  • Paul Kehrer
    Paul Kehrer over 1 year

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

    And here's the jenkins output

    + 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
    

    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).

    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?

    • Paul Kehrer
      Paul Kehrer almost 7 years
      @burnettk I just tested pulling just debian:wheezy and see the same problem.
  • Paul Kehrer
    Paul Kehrer almost 7 years
    This is exactly it! Thank you so much. I look forward to seeing the fix upstream, but for now we can work around it by adding procps (and procps-ng on Fedora). I'll award the bounty as soon as Stack Overflow lets me (it requires a 24 hour period after a bounty is added before you can award it)
  • Prathamesh dhanawade
    Prathamesh dhanawade over 4 years
    I my case, I kinda have an idea why the error is taking place and know that rebuilding the image will cure it. Is there a way to capture "ERROR: script returned exit code 1" and try to rebuild image once more before failing the jenkins job ??