jenkinscheckout

Unify Jenkins checkout on different agents


I have approximately the following jenkins pipeline:

pipeline {
    options {
        skipDefaultCheckout(true)
    }
    agent {
        label "agent1"
    }
    
    parameters {
        booleanParam defaultValue: false, description: 'Make clean build', name: 'CLEAN'
    }
    
    stages {
        stage("Checkout") {
            steps {
                script{
                    if (params.CLEAN){
                        cleanWs()
                    }
                    checkout scm
                }
            }
        }
        stage("Debian build") {
            agent {
                label "debian"
            }
            steps {
                script {
                    if (params.CLEAN){
                        cleanWs()
                    }
                    checkout(changelog: false, scm: scm)
                }        
            }
        }
    }

}

I added skipDefaultCheckout so a user can decide to make a clean before checkout or not. I noticed though that checkout scm lines can theoretically checkout different code because they start at different time.

I think if I simply let Jenkins to checkout on it's own they will be the same and share the actual timestamp of checkout.

Is there a way I can have this functionality and still be able to do a clean checkout based on the parameter?

Jenkins help page is here


Solution

  • First of all I moved all checkouts on different nodes to the start of the pipeline.

    But nevertheless I noticed that revision time is the same on different nodes now so I think the problem is solved on Jenkins side.