Skip to content

Instantly share code, notes, and snippets.

@g19fanatic
Forked from micw/install_jenkins_plugin.sh
Last active January 4, 2019 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save g19fanatic/4bb10ace936b51c5f4243fb852b2d4cd to your computer and use it in GitHub Desktop.
Save g19fanatic/4bb10ace936b51c5f4243fb852b2d4cd to your computer and use it in GitHub Desktop.
Script to install one or more jenkins plugins including dependencies while jenkins is offline

Add any additional plugins to the text file listing them (space delimited).

run the following command: ./install_jenkins_plugins.sh cat pluginsToDownload

cd plugins .././bulkRename.sh hpi jpi

#!/bin/bash
old=$1
new=$2
files=`ls`
for f in $files; do
newName=`echo $f | sed "s/$old/$new/"`
echo "Moving $f -> $newName"
mv $f $newName
done
#!/bin/bash
set -e
if [ $# -eq 0 ]; then
echo "USAGE: $0 plugin1 plugin2 ..."
exit 1
fi
plugin_dir=./plugins/
#file_owner=jenkins.jenkins
#mkdir -p /var/lib/jenkins/plugins
installPlugin() {
if [ -f ${plugin_dir}/${1}.hpi -o -f ${plugin_dir}/${1}.jpi ]; then
if [ "$2" == "1" ]; then
return 1
fi
echo "Skipped: $1 (already installed)"
return 0
else
echo "Installing: $1"
curl -L --silent --output ${plugin_dir}/${1}.hpi https://updates.jenkins-ci.org/latest/${1}.hpi
return 0
fi
}
for plugin in $*
do
installPlugin "$plugin"
done
changed=1
maxloops=100
while [ "$changed" == "1" ]; do
echo "Check for missing dependecies ..."
if [ $maxloops -lt 1 ] ; then
echo "Max loop count reached - probably a bug in this script: $0"
exit 1
fi
((maxloops--))
changed=0
for f in ${plugin_dir}/*.hpi ; do
# without optionals
#deps=$( unzip -p ${f} META-INF/MANIFEST.MF | tr -d '\r' | sed -e ':a;N;$!ba;s/\n //g' | grep -e "^Plugin-Dependencies: " | awk '{ print $2 }' | tr ',' '\n' | grep -v "resolution:=optional" | awk -F ':' '{ print $1 }' | tr '\n' ' ' )
# with optionals
deps=$( unzip -p ${f} META-INF/MANIFEST.MF | tr -d '\r' | sed -e ':a;N;$!ba;s/\n //g' | grep -e "^Plugin-Dependencies: " | awk '{ print $2 }' | tr ',' '\n' | awk -F ':' '{ print $1 }' | tr '\n' ' ' )
for plugin in $deps; do
installPlugin "$plugin" 1 && changed=1
done
done
done
#echo "fixing permissions"
#chown ${file_owner} ${plugin_dir} -R
echo "all done"
ace-editor
analysis-core
ansible
ant
antisamy-markup-formatter
apache-httpcomponents-client-4-api
async-http-client
authentication-tokens
bitbucket
bitbucket-approve
bitbucket-build-status-notifier
bouncycastle-api
branch-api
build-pipeline-plugin
build-timeout
build-token-root
cloudbees-bitbucket-branch-source
cloudbees-folder
command-launcher
conditional-buildstep
config-file-provider
credentials
credentials-binding
dashboard-view
delivery-pipeline-plugin
deployment-notification
display-url-api
docker-commons
docker-workflow
durable-task
email-ext
external-monitor-job
git
git-client
github
github-api
github-branch-source
git-parameter
git-server
gradle
handlebars
handy-uri-templates-2-api
jackson2-api
javadoc
jdk-tool
jenkins-jira-issue-updater
jira
jira-ext
jira-steps
JiraTestResultReporter
job-dsl
jquery
jquery-detached
jsch
junit
ldap
lockable-resources
mailer
managed-scripts
mapdb-api
matrix-auth
matrix-project
maven-plugin
mercurial
metrics
momentjs
multiple-scms
naginator
nested-view
node-iterator-api
p4
pam-auth
parameterized-trigger
pipeline-build-step
pipeline-github-lib
pipeline-graph-analysis
pipeline-input-step
pipeline-milestone-step
pipeline-model-api
pipeline-model-declarative-agent
pipeline-model-definition
pipeline-model-extensions
pipeline-rest-api
pipeline-stage-step
pipeline-stage-tags-metadata
pipeline-stage-view
plain-credentials
powershell
project-inheritance
promoted-builds
publish-over
publish-over-ssh
puppet
rebuild
resource-disposer
run-condition
scm-api
script-security
ssh
ssh-agent
ssh-credentials
ssh-slaves
structs
subversion
support-core
timestamper
token-macro
trilead-api
vagrant
variant
vsphere-cloud
windows-slaves
workflow-aggregator
workflow-api
workflow-basic-steps
workflow-cps
workflow-cps-global-lib
workflow-durable-task-step
workflow-job
workflow-multibranch
workflow-scm-step
workflow-step-api
workflow-support
ws-cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment