Home > other >  How does Jenkins determine that a stage in a pipeline has finished, so that it can continue?
How does Jenkins determine that a stage in a pipeline has finished, so that it can continue?

Time:06-07

If I got a Jenkins-file like this one:

...
stage("Clone Repo") {
        steps {
            sh "git clone https://github.com/jenkins-docs/simple-java-maven-app.git"
        }
    }
    stage("Build") {
        steps {
            dir("simple-java-maven-app") {
                sh ("mvn clean install")
            }
        }
    }
    stage("Test") {
        steps {
            dir("simple-java-maven-app") {
                sh ("mvn test")
            }
        }
    }
...

How is in the shown example blocking behaviour accomplished? Respectively: How does Jenkins determine that the git clone-command has finished, so that the next stage can start?

CodePudding user response:

A pipeline stage completes when the final method completes. In this situation for the Clone Repo, then that would be when the sh step method completes. A method completes when it returns an exit code to Jenkins Pipeline. In this situation, it would be when the sh step method returns an exit code to Jenkins Pipeline, which would correspond to when git returns an exit code to the shell interpreter (up the stack).

  • Related