How to programmatically add work to a view in hudson

I have a Java program that manages automatically generated jobs for a set of hudson servers. There is no problem creating, deleting or updating a job (config) using the hudson remote API. I also managed to create hudson views and create a new work to view hudson. But I still need to know how to add an existing task to the view and how to delete it again.

Are there URLs with arguments that execute the job (e.g. to create a job)?

+5
source share
2 answers

You can execute the groovy script through the Hudson CLI API , which will add the job to the view. Here is the code:

import hudson.model.*

def job = Hudson.instance.getView("View").getItem("Job")
Hudson.instance.getView("View2").add(job)

and command for CLI:

java -jar hudson-cli.jar -s http://`your-hudson-server` groovy myScript.groovy

Note that you must have the groovy support plugin installed on your Hudson instance in order to execute the script. You can install it on: http: // your-hudson-server/ pluginManager.

+5
source

There is no api configuration to view (at least not in Jenkins v1.424.6), but it should be possible to add a task to view foousing the form in http://[jenkins-host]/view/foo/configure(sending to http://[jenkins]/view/foo/configSubmit).

If you use Java, HTMLUnit, or HttpClient Apache, HttpComponents can help you with this.

+1
source

All Articles