Running pyinstaller with Jenkinsfile

Viewed 41

I'm very new to using docker and Jenkinfiles in Jenkins. Currently, I want to run a docker container (pyinstaller-windows) on linux, so I wrote the following Jenkinsfile to test it:

pipeline {
    agent none
    stages {
        stage('Deliver') {
            agent {
                docker {
                    image 'cdrx/pyinstaller-windows:python3'
                }
            }
            steps {
                sh 'cd app/'
                sh 'pip install -r requirements.txt'
                sh 'cd gui'
                sh './gui_to_exe.sh' //containing pyinstaller command
            }
            post {
                success {
                    archiveArtifacts 'appName.exe'
                }
            }
        }
    }
}

After running it in Jenkins, I received the following error message:

     cdrx/pyinstaller-windows:python3 cat
        $ docker top 8...5 -eo pid,comm
        [Pipeline] // withDockerContainer
        [Pipeline] }
        [Pipeline] // withEnv
        [Pipeline] }
        [Pipeline] // node
        [Pipeline] }
        [Pipeline] // stage
        [Pipeline] End of Pipeline
        java.io.IOException: Failed to run top '8...5'. Error: Error response
    from daemon: Container 8...5 is not running.

at org.jenkinsci.plugins.docker.workflow.client.DockerClient.listProcess(DockerClient.java:152)
    at org.jenkinsci.plugins.docker.workflow.WithContainerStep$Execution.start(WithContainerStep.java:201)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:322)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:196)
    at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:124)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:47)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
    at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(Docker.groovy:140)
    at org.jenkinsci.plugins.docker.workflow.Docker.node(Docker.groovy:66)
    at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(Docker.groovy:125)
    at org.jenkinsci.plugins.docker.workflow.declarative.DockerPipelineScript.runImage(DockerPipelineScript.groovy:54)
    at 
...

What am I doing wrong here?

1 Answers

Check the following minimal pipelinne. I fixed the issues I observed. Other than that, I'm not sure from where you are getting the app directory. Probably you may want to mount the workspace to your Container if you have any sources in the host machine.

pipeline {
    agent any
    stages {
        stage('Deliver') {
            agent {
                docker {
                    image 'cdrx/pyinstaller-windows:python3'
                    args "--entrypoint=''"
                }
            }
            steps {
                echo "Something"
                sh '''
                    cd app/
                    pip install -r requirements.txt
                    cd gui
                    ./gui_to_exe.sh
                '''
            }
            post {
                success {
                    archiveArtifacts 'appName.exe'
                }
            }
        }
    }
}
Related