Issue
I have a few existing jobs created by the Jenkins UI and i'm trying to run them as part of a pipeline script.
The problem i'm facing is that in most jobs i have "Active Choices Reactive Parameter" parameters which is being populated by a scriptler script and requires a value selection to build the job.
My goal is to automatically build the job and to set by code a test value but everything i tried until now failed. for example:
stage('Test') {
build job: 'Test-regression', parameters: [
[$class: 'WHideParameterValue', name: 'envListDb', value: 'TestEnvironmentListByOperator'],
string(name: 'Operator', value: 'TestOp'),
validatingString(name: 'OperatorValidation', value: 'TestOp'),
string(name: 'Environment', value: 'Test'),
validatingString(name: 'EnvironmentValidation', value: 'Test')
]
}
When running this i got "the parameter 'Operator' did not have the type expected by Test-regression. Converting to Active Choices Reactive Parameter" so as mentioned i guess the problem is not having an actual selected value for the build itself.
I might be doing it the wrong way but i would appreciate if anyone has an idea which would spare me the need to create a new layout just for the pipeline testing. Thanks
Solution
As I understand here Test-regression
is a standalone pipeline with input params Operator
and Environment
. You want to invoke Test-regression
pipeline in another pipeline for which you have shared the code.
I had a similar requirement and following code worked for me. I have modified the code to suit your requirement:
env.TestOp="your_val_1";
env.Test="your_val_2";
stage ('Test') {
steps {
build job: 'Test-regression', parameters: [
string(name: 'Operator', value: "${TestOp}"),
string(name: 'Environment', value: "${Test}")
]
}
}
Answered By - Yash
Answer Checked By - Senaida (JavaFixing Volunteer)