Jenkins 所有构建参数(键和值)连接为单个字符串
Jenkins all build parameters(key and value) concatenation as single string
我正在创建一个 jenkins 管道,它将所有构建参数连接为单个字符串(因为我们需要在 cURL api 调用中将其作为 shell 参数)
pipeline {
agent any
stages {
stage('Test') {
steps {
script {
for (entry in params) {
echo "Build param: ${entry.key} - ${entry.value}"
}
}
}
}
}
}
你能帮我把所有的参数连接成一个字符串吗==>
"param1=value1¶m2=value¶m3=value3&..."
等
为了检索 key
和 value
参数,您需要使用 getKey()
和 getValue()
函数。对于字符串连接,我使用了 +
运算符。
pipeline {
agent any
stages {
stage('Test') {
steps {
script {
def curl = ""
for (entry in params) {
curl += entry.getKey() + "=" + entry.getValue() + "&"
}
}
}
}
}
}
我正在创建一个 jenkins 管道,它将所有构建参数连接为单个字符串(因为我们需要在 cURL api 调用中将其作为 shell 参数)
pipeline {
agent any
stages {
stage('Test') {
steps {
script {
for (entry in params) {
echo "Build param: ${entry.key} - ${entry.value}"
}
}
}
}
}
}
你能帮我把所有的参数连接成一个字符串吗==>
"param1=value1¶m2=value¶m3=value3&..."
等
为了检索 key
和 value
参数,您需要使用 getKey()
和 getValue()
函数。对于字符串连接,我使用了 +
运算符。
pipeline {
agent any
stages {
stage('Test') {
steps {
script {
def curl = ""
for (entry in params) {
curl += entry.getKey() + "=" + entry.getValue() + "&"
}
}
}
}
}
}