I am creating a jenkins-pipeline which will concatenate all build params as single string (as we need this in cURL api call as a shell argument)
pipeline {
agent any
stages {
stage('Test') {
steps {
script {
for (entry in params) {
echo "Build param: ${entry.key} - ${entry.value}"
}
}
}
}
}
}
Could you please help me to concatenate all params as single string ==>
"param1=value1¶m2=value¶m3=value3&..."
etc.
CodePudding user response:
In order to retrieve key
and value
of the parameters you will need to use getKey()
and getValue()
functions. For string concatenation I used
operator.
pipeline {
agent any
stages {
stage('Test') {
steps {
script {
def curl = ""
for (entry in params) {
curl = entry.getKey() "=" entry.getValue() "&"
}
}
}
}
}
}