我正在尝试使用 curl、http-get 向 Jenkins 发送 boolean 参数,但没有成功。需要有人告诉我这里有什么问题。
我确实尝试将其发送为 true
, True
和 1
但这都不起作用。
jenkins 中的作业被设置为管道并被参数化。从 GUI 添加了 3 个参数:
默认值如下:
流水线代码:
stage ('bools') {
echo 'bool 1 is:' + params.bp1
echo 'bool 2 is:' + params.bp2
echo 'string is:' + params.sp
}
用于调用构建的命令(在浏览器或 postman 中):
http://X.X.X.X/jenkins/job/bool_debug/buildWithParameters?token=booltest&bp1=true&bp2=false$sp='this is text from param'
预期结果是
bool 1 is:true
但得到了 bool 1 is:false
.从 API 调用时,Jenkins 没有更改(勾选复选框) boolean 参数。其他方式:我得到的:
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] stage
[Pipeline] { (bools)
[Pipeline] echo
bool 1 is:false
[Pipeline] echo
bool 2 is:false
[Pipeline] echo
string is:'this is text from param'
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
Finished: SUCCESS
它应该是什么:
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] stage
[Pipeline] { (bools)
[Pipeline] echo
bool 1 is:true <--------------------------
[Pipeline] echo
bool 2 is:false
[Pipeline] echo
string is:'this is text from param'
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
Finished: SUCCESS
最佳答案
面对同样的问题,认为是Jenkins的bug。我最终创建了另一个管道,它使用 params 作为解决方法触发所需的管道。
关于api - Jenkins - 如何使用 curl、http 发送 boolean 参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54179003/