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)?
You can execute a groovy script through the Hudson CLI API that will add a job to a view. Here is the code:
and the command for the CLI is:
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 .There is no api for view configuration (at least not in Jenkins v1.424.6), but it should be possible to add a job to view
foo
by using the form athttp://[jenkins-host]/view/foo/configure
(submitting tohttp://[jenkins]/view/foo/configSubmit
).If you are using Java, HTMLUnit or HttpClient of Apache HttpComponents can help you with this.