Updating a config.xml file for a job through Java code

27 views
Skip to first unread message

Karthik V S

unread,
Jun 20, 2014, 8:29:49 PM6/20/14
to jenkin...@googlegroups.com
Hi,

I have an custom job configuration page that is a subset of the options present in the main configuration page.

My requirement is to persist the changes done in this page to the config.xml file of the project?

Could anyone provide me valuable pointers on this?

Ulli Hafner

unread,
Jun 21, 2014, 4:27:14 AM6/21/14
to jenkin...@googlegroups.com
Can you please explain in more detail? What is a custom job configuration page? A web page outside of the Jenkins web app?

You can update the job configuration using the remote api.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

signature.asc
Message has been deleted
Message has been deleted

Ulli Hafner

unread,
Jun 25, 2014, 4:40:24 AM6/25/14
to jenkin...@googlegroups.com, Karthik V S
Please use the mailing list so others can participate.

I still do not understand your use case. Do you want to replace the job configuration page with a simpler one? When you are running a plugin inside Jenkins then there is no need to use the remote API, this is only required if you write an additional application... 

Am 24.06.2014 um 23:46 schrieb Karthik V S <karthik...@gmail.com>:

Hi Ullrich,

Thank you for your reply. I now know which api to call to obtain the job configuration config.xml and to post the job configuration.xml.

However, my query is that, where should the code for reading the xml file and posting the xml file be placed?

Should it be in the class that extends from Plugin or should it be in a some other class?

If it is the former, could you please let me know whether to place the code in the start or the configure method?

If it is the latter, could you please let me know in which class should i place that code and what Hudson class should that class extend reply?

Apologies for the numerous questions. But have been stuck on this for the past two days. Any info would be really valuable.

Thanks,
Karthik
signature.asc

Karthik V S

unread,
Jun 25, 2014, 3:28:12 PM6/25/14
to Ulli Hafner, jenkin...@googlegroups.com
Hi Ullrich,

I am trying to supplement the existing configuration page that have a lot of options with a custom set of configurations to make configuring a job easier as shown in the screenshot. I want these configuration to override the existing configurations for the job. I have a separate jelly page with these options as shown in the image.

I require guidance to do that as I am very new to Jenkins. 

I researched on the Items.XSTREAM.Alias, which i presume updates config.xml for the job, however I am not unable to figure what to exactly use for this purpose.

Need help on this.

Screen Shot 2014-06-25 at 12.22.28 PM.png

Karthik V S

unread,
Jun 25, 2014, 9:16:08 PM6/25/14
to Ulli Hafner, jenkin...@googlegroups.com
Adding on to this, my use case is that

The new configuration page that I have created, should update the config.xml created for the job using the job name text box as shown. Is it possible to do that using a class that extends from hudson.model.JobProperty? Please find the updated screenshot attached.

One screenshot shows the Easy Configuration Link. Clicking on that link navigates me to my Easy Configuration Page which has the subset of options as shown in the second screenshot

After clicking on Submit, the job configuration should update with the given options. How can I achieve that?

Thanks,
Karthik
Screen Shot 2014-06-25 at 6.13.19 PM.png
Screen Shot 2014-06-25 at 6.15.14 PM.png
Reply all
Reply to author
Forward
0 new messages