Skip to content

Instantly share code, notes, and snippets.

@hgomez
Last active December 11, 2023 07:47
Show Gist options
  • Star 45 You must be signed in to star a gist
  • Fork 17 You must be signed in to fork a gist
  • Save hgomez/2048146ddfb04ca42d91 to your computer and use it in GitHub Desktop.
Save hgomez/2048146ddfb04ca42d91 to your computer and use it in GitHub Desktop.
Mass install/update of Jenkins Plugins

Scripted Jenkins Plugins install

Jenkins has a very rich catalog of plugins and it's quite easy to install and update them via UI. BTW, when you want to add tons of plugin via UI, it's a fairly long and boring procedure.

Hopefully, mass installation (or update) could be easy using a simple bash script (curl/python required) :

Create a file containing plugins to be installed (or updated), ie iplugins :

analysis-core
audit-trail
build-flow-plugin
buildgraph-view
build-metrics
build-timeout
changelog-history
claim
config-file-provider
configurationslicing
console-column-plugin
dashboard-view
greenballs
htmlpublisher
mercurial
sonar
ssh-agent
thucydides
timestamper
viewVC
WebSVN2

If you want some plugins to be excluded, for example those found in dependency list, create a second file with excluded list (ie, xplugins):

ant
antisamy-markup-formatter
credentials
cvs
external-monitor-job
javadoc
ldap
mailer
matrix-auth
maven-plugin
pam-auth
ssh-credentials
ssh-slaves
subversion
translation
windows-slaves

Then get script :

curl -L https://raw.githubusercontent.com/hgomez/devops-incubator/master/forge-tricks/batch-install-jenkins-plugins.sh -o batch-install-jenkins-plugins.sh
  • --plugins (or -p) is for file containing plugins to be installed

  • --excludedplugins (or -e) is for file containing plugins to be excluded

  • --plugindir (or -p) is for directory path to copy plugins (.jpi)

    batch-install-jenkins-plugins.sh --plugins iplugins --excludedplugins xplugins --plugindir /var/lib/myjenkins/plugins

batch-install-jenkins-plugins.sh will download json file containing up to date plugins and will download plugins to be installed and non optional dependent plugins

Of course, better run this script when Jenkins is down to avoid runtime issue.

Script powo !

@samrocketman
Copy link

@OnlineGBC
Copy link

Is there a way to modify this script so it only downloads all the plugins and dependencies? That way, it will help with all offline installations as well.

@jseadragon
Copy link

Is there any chance you could provide a license for this?

@marcosfreire
Copy link

AWESOME

@atlc
Copy link

atlc commented Feb 14, 2020

This saved me so much time during a migration from one platform to another. Thank you so much!!

Copy link

ghost commented Apr 22, 2020

The script throws errors while runnint python:
SyntaxError: invalid syntax
File "", line 1
import sys, json; print json.load(sys.stdin)["plugins"]["mailer:1.32"]["version"]

at: json.load

@lukolszewski
Copy link

The script throws errors while runnint python: SyntaxError: invalid syntax File "", line 1 import sys, json; print json.load(sys.stdin)["plugins"]["mailer:1.32"]["version"]

at: json.load

It's because it has been written for python2. To use with python3 you have to surround all print arguments with brackets like this:
python -c "import sys, json; print(json.load(sys.stdin)[\"plugins\"][\"$FPLUGIN\"][\"url\"])"

It's working fine for me following this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment