1

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

1 回答 1

0

您可以按照“将条件构建步骤转换为 Jenkins 流水线”进行操作,其中显示了使用条件的声明性流水线(基于 DSL)的示例:

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!"
            }
        }
    }
}
于 2019-08-04T13:47:38.573 回答