如何编写管道以丢弃旧版本? [英] How to write Pipeline to discard old builds?
问题描述
groovy语法生成器不适用于示例步骤properties: Set Job Properties
.我选择了Discard old builds
,然后在Max # of builds to keep
字段中输入了10
,然后选择了Generate Groovy
,但没有任何显示.
The groovy syntax generator is NOT working for sample step properties: Set Job Properties
. I've selected Discard old builds
and then entered 10
in the Max # of builds to keep
field and then Generate Groovy
and nothing shows up.
Jenkins版本:2.7
Jenkins version: 2.7
推荐答案
您可以使用properties
方法,该方法嵌套在BuildDiscarderProperty
中,最终具有您要设置的密钥.我仍然没有可靠的方法来查找每个键的正确语法.经过大量的猜测和检查:
You can use the properties
method which, nested within the BuildDiscarderProperty
eventually has the key you want to set. I still don't have a solid way to look up the correct syntax of each key. After much guessing and checking:
properties([[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10']]]);
请注意,此代码段适用于脚本化语法.
Note that this snippet is for scripted syntax.
这篇关于如何编写管道以丢弃旧版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!