如何在Hudson中以编程方式向视图添加作业 [英] How to programmatically add a job to a view in hudson
问题描述
我有一个Java程序,它控制着一组hudson服务器自动生成的作业.使用hudson远程API创建,删除或更新job(config)没问题.我还设法创建了哈德逊视图,并为哈德逊视图创建了新工作.但是我仍然需要知道如何向视图中添加一个已经存在的作业,以及如何再次将其删除.
I have a Java program controlling automatically generated jobs for a set of hudson servers. It is no problem to create, delete or update job(config)s using the hudson remote API. I also managed it to create hudson views and to create a new job for a hudson view. But I still need to know how to add an already existing job to a view and how to remove it again.
是否存在带有参数的网址(例如创建工作)?
Are there URLs with arguments doing the job (like for the job creation)?
推荐答案
您可以通过 Hudson CLI API ,它将添加作业到视图中.这是代码:
You can execute a groovy script through the Hudson CLI API that will add a job to a view. Here is the code:
import hudson.model.*
def job = Hudson.instance.getView("View").getItem("Job")
Hudson.instance.getView("View2").add(job)
,并且CLI的命令是:
and the command for the CLI is:
java -jar hudson-cli.jar -s http://`your-hudson-server` groovy myScript.groovy
请注意,您必须在Hudson实例上安装Groovy支持插件才能执行脚本.您可以将其安装在:http://your-hudson-server
/pluginManager上.
Note that you must have Groovy support plugin installed on your Hudson instance in order to execute the script. You can install it on: http://your-hudson-server
/pluginManager .
这篇关于如何在Hudson中以编程方式向视图添加作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!