如何在 jenkins 作业 DSL groovy 脚本中设置监视器视图的作业顺序?
How to set job order for monitor view in jenkins job DSL groovy script?
我正在使用 DSL 脚本创建构建监视器视图,但 API 中没有设置作业顺序的方法。创建视图后,我可以在配置中手动设置顺序,但我需要在脚本中执行此操作。
我使用 https://jenkinsci.github.io/job-dsl-plugin/#path/buildMonitorView 作为参考。我怀疑唯一可能的方法是配置(关闭)方法,但我仍然会有同样的问题如何去做。
我当前的代码:
biuldMonitorView("name-of-the-view") {
jobs {
regex("some regex to include jobs")
recurse()
}
// I would expect something like:
view {
orderByFullName()
}
}
经过反复试验和 println
到处调用后,我找到了这个解决方案:
biuldMonitorView("name-of-the-view") {
jobs { // This part is as before
regex("some regex to include jobs")
recurse()
}
// The solution:
view.remove(view / order)
view / order(class: "com.smartcodeltd.jenkinsci.plugins.buildmonitor.order.ByFullName")
}
以上解决方案将作业顺序设置为 "Full name" 而不是默认的 "Name"。
我在 Configure SVN section of job-dsl-plugin, fully qualified names of job order options can be found in the source of jenkins-build-monitor-plugin 找到了 remove
想法。
我今天遇到了同样的问题,并设法让 Aivaras 的提案以下列方式发挥作用:
buildMonitorView("name-of-the-view") {
// Set properties like jobs
jobs {
regex("some regex to include jobs")
recurse()
}
// Directly manipulate the config to set the ordering
configure { view ->
view.remove(view / order)
view / order(class: "com.smartcodeltd.jenkinsci.plugins.buildmonitor.order.ByFullName")
}
我正在使用 DSL 脚本创建构建监视器视图,但 API 中没有设置作业顺序的方法。创建视图后,我可以在配置中手动设置顺序,但我需要在脚本中执行此操作。
我使用 https://jenkinsci.github.io/job-dsl-plugin/#path/buildMonitorView 作为参考。我怀疑唯一可能的方法是配置(关闭)方法,但我仍然会有同样的问题如何去做。
我当前的代码:
biuldMonitorView("name-of-the-view") {
jobs {
regex("some regex to include jobs")
recurse()
}
// I would expect something like:
view {
orderByFullName()
}
}
经过反复试验和 println
到处调用后,我找到了这个解决方案:
biuldMonitorView("name-of-the-view") {
jobs { // This part is as before
regex("some regex to include jobs")
recurse()
}
// The solution:
view.remove(view / order)
view / order(class: "com.smartcodeltd.jenkinsci.plugins.buildmonitor.order.ByFullName")
}
以上解决方案将作业顺序设置为 "Full name" 而不是默认的 "Name"。
我在 Configure SVN section of job-dsl-plugin, fully qualified names of job order options can be found in the source of jenkins-build-monitor-plugin 找到了 remove
想法。
我今天遇到了同样的问题,并设法让 Aivaras 的提案以下列方式发挥作用:
buildMonitorView("name-of-the-view") {
// Set properties like jobs
jobs {
regex("some regex to include jobs")
recurse()
}
// Directly manipulate the config to set the ordering
configure { view ->
view.remove(view / order)
view / order(class: "com.smartcodeltd.jenkinsci.plugins.buildmonitor.order.ByFullName")
}