We want to upgrade a Jenkins instance from 2.332.2 (from May 2022) to 2.440.1 (2024). Because this is such a large jump of LTS versions - we were planning to do a rolling upgrade by upgrading to every other LTS version until we reach 2.440.1 .
Is there a strategy recommended for this type of upgrade? Not sure if this is the right approach. Thanks in advance.
It all depends how complex are your jobs and the plugins that you use.
The biggest change is the required java version. You need at least java 11, but better to directly go to java 17.
Take look at
Another approach might be to do a single jump as I described here:
Anyway make sure you take backups, ideally you first try with a test instance and check if everything works.
snapshots are hugeā¦ read everything and try to account for changes. Hope my guide (linked above helps). I always consider myself a student of work; but feel free to drop questions here.
Hi @mawinter69, Thanks for your suggestion, do you know how we can get list of all used and unused plugins from jenkins, there is one plugins called plugin-usages-plugin: Plugin Usage but its not compatible with our jenkins version i.e. 2.332.3 as its requires jenkins version 2.361.4 and higher to use, could you please suggest on how we can get list of all used and unused plugins?
there is a gui command < http://<jenkins-url>/script> you can run to list all plug insā¦ I used it a number of month ago now. But itās not super useful:
Many plugins are pipeline only and just provide steps. And if they are used in Jenkinsfile you have no chance just look in the jobs config.
You would need to scan also the workflow xml files of builds (there are the descriptor ids written), but that is quite time consuming and you need a mapping from descriptor ID to plugin.
I would go to plugin manager and look at the installed plugins. Start with those plugins that can be uninstalled. For each you need to look what it is doing and think if it might be used.
There are some type of plugins where you might have several installed but only one of them is used at a time. E.g. the security realm plugins. Iāve seen many instances where ldap, pam, AD plugins are installed. You need only one of them.
Similar for authorization with Matrix Auth and Role-strategy
In the end you have the potential to remove maybe a few plugins.
What one might consider is removing all the blue ocean plugins (Blue ocean is not actively developed anymore) and stage view plugin and replace it with Pipeline Graph View
Hi @mwp565733,
I refer same document for listing out all installed plugins but here what I want is to get all plugins which are in used, as installed plugins list is hug hence its time consuming to go through each & every plugin to check whether it is in used or not
Sorry @snehalhingane I was OoO for a few days on holiday:
As for usage, I definitively suggest the Plugin-usage-plugin linked above by MAWinter69. Itās better than nothing, I found it useful while ātending the weedsā in the plugin garden. You can also try to deactivate plugins that are not being used. If there are dependencies it will let you know in the UI that āThis plug is is required for plugin ABCā and you will not be allowed to deactivate it.
That being said: I build up a script that you can run from the server to query mission critical plug-ins. this will run thru all executed jobs and extract which plug in were used and what version: this is a bash shell that you run in $(JENKINS_HOME)/jobs
# runs thru all jobs that have been executed, looking for config.xml files and outputs strings with plugins= to jobs_with_plugins.txt
grep -lR --include=config.xml "plugin=" > jobs_with_plugins.txt
#visit each job that used a plugin collate all plugin references in to one file
while read p; do
tmp=$(cat "${p}" | grep "plugin=")
echo ${tmp#*plugin=\"} >> usedPlugins.txt
done <jobs_with_plugins.txt
# clean up out put
sed -i -e 's/> </\n/g' usedPlugins.txt
while read q; do
tmp1=${q#*plugin=\"}
echo ${tmp1%%\"*} >> usedPlugins1.txt
done <usedPlugins.txt
# remove working files, uncomment below if interested
rm jobs_with_plugins.txt
rm usedPlugins.txt
mv usedPlugins1.txt usedPlugins.txt
# display deduped list, though usedPlugins.txt remains duplicated.
sort usedPlugins.txt | uniq > usedPlugins.txt
I do have this running and tested in my RHEL 8.9 box.
Run Markusā suggestions . I assume you copied from the blog post, there could be invisible characters that are giving you issues. I typed it all in without issues before
After creating the shell script.
From command line,
dos2unix listUsedPlugins.sh
will clean up those characters
Then run it ./listUsedPlugins.sh
Sorry I was having issues dropping in the snippet properly, probably captured the character
your jobs folder isnāt populated, aside from subfolders
your jobs donāt use plugins in the config.xml file
More probable
something was introduced as a bug
Comment out the rm and mv lines and look at the resultant files.
Jobs_with_plugins.txt lists all jobs that have plugins mentioned
UsedPlugins.txt is initially a non-clean list of plugins
UsedPlugins1.txt is cleaned up (currently blank).
Iād also try keying in my script directly in to unix, instead of copy paste.
run jenkins 2.440 from docker and install all these plugins (iirc there is a cli option to make this snappier)
make a backup of your production instance
copy jenkins.war and the plugins folder from your docker version to your prod version
restart
It might take a while depending on how many plugins and jobs you have as the data will need to migrate, but if the plugins are well written they should be able to get all the data upgraded.
Depending on your plugins list, some plugins might have been abandoned, not rebuilt and broken/incompatible. It is not possible to tell what each individual use case is.
Something you can try to do in preparation is to identify all the non necessary plugins you might have and uninstall them and only keep the ones you really need. Be proactive in removing unmaintained plugins.
Hi @mawinter69,
Thanks, I was upgrading Jenkins version from 2.332.3 to latest LTS version i.e. 2.440.3
For preparing image we have done below -
We have made changes in Dockerfile according to LTS version
Updated required plugins (Not all) - pointed plugins version in plugins.txt
Deploy the image with LTS version
Now issue is, If we check logs it fails to load most of the plugins
logs as below,
Failed Loading plugin SSH server v3.322.v159e91f6a_550 (sshd)
Failed Loading plugin Matrix Authorization Strategy Plugin v3.2.2 (matrix-auth)
Failed Loading plugin Jenkins promoted builds plugin v867.v7c3a_b_83a_eb_79 (promoted-builds)
Failed Loading plugin Azure AD Plugin v185.v3b416408dcb1 (azure-ad)
Failed Loading plugin Jenkins GIT server Plugin v1.11 (git-server)
Failed Loading plugin Pipeline: Deprecated Groovy Libraries v588.v576c103a_ff86 (workflow-cps-global-lib)
Failed to scout io.jenkins.blueocean.service.embedded.analytics.BrowserAndOperatingSystemAnalyticsProperties
What my next plan was:
first remove existing plugins folder
point all latest plugin version in plugins.txt file
deploy the image with these change and see how it goes?
Also there are lot of deprecated and suspended plugins in our plugin list, how can we handle that?
could you please suggest on the same
Thanks in advance.
Thanks @mawinter69
I will test this out, Also there are lot of deprecated, suspended not found plugins in our plugin list, how can we handle that?
could you please suggest on the same
You can see in the installed plugins link in Jenkins which plugins are deprecated. Suspended plugins are no longer distributed afaik, so you canāt even install them anymore as they are not offered on the update site.
You should remove from your plugins.txt file