Reputation: 593
I want to be able to pass a List variable to the Build command in Jenkinsfile something like:
stage('test') {
def listName = []
build job: "/job/jobname", parameters: listName, propagate: false
}
When I try something like this I get an error:
hudson.model.PasswordParameterValue~PasswordParameterValue(name: String, value: String, description: String)}[], propagate?: boolean, quietPeriod?: int, wait?: boolean): java.lang.ClassCastException: class org.jenkinsci.plugins.workflow.support.steps.build.BuildTriggerStep.setParameters() expects java.util.List but received class java.lang.String
Upvotes: 3
Views: 9877
Reputation: 593
Was able to get through this by using below code:
stage('test') {
def listName = []
listName .add([$class: 'StringParameterValue', name: "${listKey}", value: "${list.value}"])
build job: "/job/jobname", parameters: listName, propagate: false
}
Upvotes: 2
Reputation: 402
You should pass Map
to parameters
:
stage('test') {
def listName = [string(name: 'PARAM_NAME', value: "PARAM_VALUE")]
build job: "/job/jobname", parameters: listName, propagate: false
}
Upvotes: 0