如何在Jenkins中使用条件语句。堵塞
我正在尝试根据变量设置詹金斯管道作业的超时。
我有这样的东西:
pipeline {
agent any
options {
timeout(time:6, unit:'HOURS')
}
}
我希望只有在变量为真时才能设置此超时。类似的事情:
pipeline {
agent any
options {
if (timerCause) {
timeout(time:6, unit:'HOURS')
}
}
}
如果> 在选项块中的语句时,我无法使用进行此操作。任何指针都会很棒。谢谢 :)
I am trying to set a timeout on a Jenkins pipeline job based on a variable.
I have got something like this:
pipeline {
agent any
options {
timeout(time:6, unit:'HOURS')
}
}
I will like this timeout to be set only when a variable is true. Something like this:
pipeline {
agent any
options {
if (timerCause) {
timeout(time:6, unit:'HOURS')
}
}
}
I can't do this with if
or when
statements in the options block. Any pointers would be great. Thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果未设置标志,您如何设置默认值。
How about you set a default value if the flag is not set.
不知道
timercause
是什么,也不愿意猜测,我只推荐三元运营商:Not knowing what a
timerCause
is, and not willing to guess, I'd just recommend the ternary operator: