load the xml from disk and POST it to jenkins_url/jobs/___/config.xml

On 27 July 2012 09:16, Michaël Pailloncy <[email protected]> wrote:

> Thanks a lot !
> I just watched the configuration slicing plugin thinking it might help me.
> But like your solution, it needs to knows which properties to modify.
> I'm in a case that I know that the config.xml file has been modified, but
> I don't anything about what was modified.
>
> Any other suggestion ?
>
>
>
> 2012/7/27 Frederik Fromm <[email protected]>
>
>> My best try to update jobs' config was using a groovy script with the
>> groovy plugin. Create a job object from an xml file using XStream.fromXml
>> and then create or get a job from your jenkins instance, store the values
>> of the loaded properties into the second job instance and do job.save().
>> That should work.
>>
>> This way I have patched lots of jobs where the config slicing plugin
>> could not help.
>>
>> Regard, Frederik
>>
>> 2012/7/27 Michaël Pailloncy <[email protected]>
>>
>>> I've tried :
>>> AbstractItem item = (AbstractItem)
>>> Jenkins.getInstance().getItem("myjob");
>>> File directoryConfigXml = item.getConfigFile().getFile().getParentFile();
>>> Item updatedItem = Items.load(item.getParent(), directoryConfigXml);
>>> Jenkins.getInstance().putItem((TopLevelItem)updatedItem);
>>>
>>> It works, but it delete and re-create the job.
>>> Nobody knows a more simple way to just reload the job configuration from
>>> disk (without having to reload all Jenkins configurations) ?
>>>
>>> Thank you in advance for any help.
>>>
>>>
>>> 2012/7/26 mpapo - Michaël Pailloncy <[email protected]>
>>>
>>>> Hi,
>>>>
>>>> I would like to reload config.xml file of a job programmatically.
>>>> I've tried :
>>>> AbstractItem item = (AbstractItem)
>>>> Jenkins.getInstance().getItem("myjob");
>>>> File directoryConfigXml =
>>>> item.getConfigFile().getFile().getParentFile();
>>>> Items.load(item.getParent(), directoryConfigXml);
>>>>
>>>> But this code portion does not reload configuration and the jobs still
>>>> has its old configuration in cache.
>>>>
>>>> If I reload Jenkins, the configuration is correctly reloaded.
>>>>
>>>> How can I reload the configuration of my job?
>>>>
>>>>
>>>>
>>>
>>
>

Reply via email to