Conditional SVN checkout in Jenkins

433 Views Asked by At

I have a Jenkins job which checks out code from many subversion URLs, however I want the job to checkout from only 1 URL based on a condition. This will prevent unnecessary checkouts and reduce the time taken for the build to complete. Please advise.

I have already looked into this answer, but it did not solve my problem.

if(value == "someValue") {
    checkout from svn URL 1
}

else if(value == "someValue2") {
    checkout from svn URL 2
} ...

and so on.
1

There are 1 best solutions below

0
VonC On

You could follow "Converting Conditional Build Steps to Jenkins Pipeline ", which shows an example of declarative pipeline (based on DSL) using conditions:

pipeline {
    agent any
    parameters {
        choice(
            choices: ['greeting' , 'silence'],
            description: '',
            name: 'REQUESTED_ACTION')
    }

    stages {
        stage ('Speak') {
            when {
                // Only say hello if a "greeting" is requested
                expression { params.REQUESTED_ACTION == 'greeting' }
            }
            steps {
                echo "Hello, bitwiseman!"
            }
        }
    }
}