如何在Jenkins中通过Groovy复制/克隆作业? [英] How to Copy/Clone a Job via Groovy in Jenkins?
本文介绍了如何在Jenkins中通过Groovy复制/克隆作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试复制现有的Jenkins作业,并使用Groovy将其重命名在同一文件夹中. 另外,我想搜索并替换git中的轮询忽略某些路径中的提交"消息框中的单词.
I'm trying to copy an existing Jenkins job and rename it in the same folder using Groovy. In addition, I would like to do a search and replace a word within git "polling ignores commits in certain paths" message box.
有可能吗?如果可以,怎么办?
Is it possible and if so how can it be done?
推荐答案
我需要解决类似的问题,并且发现了用于复制视图中所有作业的常规示例.
I was needing to solve a similar problem, and I found this groovy sample for copying all the jobs in a view.
import hudson.model.*
def viewName = "product-build-dev"
def search = "-dev"
def replace = "-prod"
def view = Hudson.instance.getView(viewName)
/* now you copy all jobs of the view copy all projects of a view */
for(item in view.getItems()) {
/* create the new project name */
newName = item.getName().replace(search , replace)
/* now copy the job */
def job = Hudson.instance.copy(item, newName)
job.save()
}
仅仅意识到我没有回答整个问题.看起来...
Just realized I didn't answer the whole question. Looking...
这篇关于如何在Jenkins中通过Groovy复制/克隆作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文