Reputation: 101
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.
Upvotes: 0
Views: 400
Reputation: 518
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() + "&"
}
}
}
}
}
}
Upvotes: 1