我试图发送布尔参数使用 curl ,http-获取到Jenkins没有成功。需要有人告诉我什么是错误的。
我确实试着把它作为true
,True
和1
发送,但这些都不起作用。
jenkins中的作业被设置为pipeline并被参数化。有3个从GUI添加的参数:
- bp 1布尔值1
- bp 2布尔值2
- sp字符串(此字符串用于检查是否发送了参数
默认值如下:
- bp 1-假
- bp 2-假
- sp -空
管道代码:
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
。Jenkins在从API调用时未更改(勾选复选框)布尔参数。在其他情况下:
我得到的是:
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
型
2条答案
按热度按时间cwtwac6a1#
面对同样的问题,我认为这是一个Jenkins的bug。我最终创建了另一个管道,它用参数触发所需的管道作为解决方案。
kd3sttzy2#
我们正在使用Jenkins 2.387.1,并使用HTTP POST和
content-type: application/x-www-form-urlencoded
在主体中传递布尔参数作为(字符串)true
,导致参数被正确启用。HTTP GET是问题所在,POST会有所帮助,或者在此期间已修复。