Save all configurations after Jenkins update

31 views
Skip to first unread message

Maciej Jaros

unread,
Feb 17, 2016, 10:34:36 AM2/17/16
to Jenkins Users
Hi.

When you save configuration of a Job after Jenkins update there are some
changes made in the config.xml (e.g. plugin version change). Since I
keep a history of all config.xml files in a repository that mess up
history of changes...

So. Is there some script or plugin that can re-save configuration of all
Jobs in a batch?

Maybe something like (?):
for job in jobs
job.save()

Regards,
Nux.

jieryn

unread,
Feb 17, 2016, 11:01:36 AM2/17/16
to Jenkins Users
Create a new freestyle job, run it @daily, or whatever. Add Groovy
script execution build step, the full script is:

for (item in hudson.model.Hudson.instance.items) {
println("Saving " + item);
item.save();
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-use...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/56C492E6.9040009%40mol.com.pl.
> For more options, visit https://groups.google.com/d/optout.

Maciej Jaros

unread,
Feb 17, 2016, 12:55:49 PM2/17/16
to jenkins...@googlegroups.com
jieryn (2016-02-17 17:01):
> for (item in hudson.model.Hudson.instance.items) {
> println("Saving " + item);
> item.save();
> }

Thanks, works great :-). I've just run it through Script Console.

Regards,
Nux.

Victor Martinez

unread,
Feb 17, 2016, 4:35:40 PM2/17/16
to Jenkins Users, mac...@mol.com.pl
Maybe the below plugin might help you:

jieryn

unread,
Feb 17, 2016, 4:39:18 PM2/17/16
to Jenkins Users
I've used JobConfigHistoryPlugin in the past. I find just using git is
easier and fits better with our existing tools, etc.
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-use...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/94def6f1-4ede-43ed-ab11-1e3baae30252%40googlegroups.com.

Victor Martinez

unread,
Feb 17, 2016, 4:56:02 PM2/17/16
to Jenkins Users

jieryn

unread,
Feb 17, 2016, 5:22:36 PM2/17/16
to Jenkins Users
Looks interesting! I haven't tried it.

It doesn't appear to work with external changes coming into the
configuration from outside the Jenkins server. (git pull)

So we'd have to make up our own minds about when to do that anyway,
this plugin porcelain doesn't seem to buy much.

On Wed, Feb 17, 2016 at 4:56 PM, Victor Martinez
> https://groups.google.com/d/msgid/jenkinsci-users/84d95c91-a0ce-43b8-b53b-917784be7fb0%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages