Merge "[Jenkins] Fixing upgrading of git plugin"
This commit is contained in:
commit
a1510195ad
@ -206,10 +206,10 @@ Methods:
|
||||
|
||||
_upgradeGitPlugin:
|
||||
Body:
|
||||
- $linux: new(conf:Linux)
|
||||
- $resource: new(sys:Resources)
|
||||
- $script: $resource.string('upgrade_git_plugin.sh')
|
||||
- $linux.runCommand($.instance.agent, $script)
|
||||
- $._environment.reporter.report($this, 'Upgrading jenkins git plugin...')
|
||||
- $template: $resource.yaml('InstallPlugins.template').bind({plugins => git})
|
||||
- $.instance.agent.call($template, $resource)
|
||||
|
||||
configureCredentials:
|
||||
Body:
|
||||
|
@ -0,0 +1,18 @@
|
||||
FormatVersion: 2.1.0
|
||||
Version: 1.0.0
|
||||
Name: Install Jenkins plugins
|
||||
|
||||
Parameters:
|
||||
plugins: $plugins
|
||||
|
||||
Body: |
|
||||
return install_plugin(args.plugins).stdout
|
||||
|
||||
Scripts:
|
||||
install_plugin:
|
||||
Type: Application
|
||||
Version: 1.0.0
|
||||
EntryPoint: install_plugins.sh
|
||||
Options:
|
||||
captureStdout: true
|
||||
captureStderr: true
|
62
murano-apps/Jenkins/package/Resources/scripts/install_plugins.sh
Executable file
62
murano-apps/Jenkins/package/Resources/scripts/install_plugins.sh
Executable file
@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "USAGE: $0 plugin1 plugin2 ..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
plugin_dir=/var/lib/jenkins/plugins
|
||||
owner=jenkins:jenkins
|
||||
|
||||
mkdir -p ${plugin_dir}
|
||||
|
||||
installPlugin() {
|
||||
plugin_name=$1
|
||||
if [ -f ${plugin_dir}/${plugin_name}.hpi -o -f ${plugin_dir}/${plugin_name}.jpi ]; then
|
||||
if [ "$2" == "1" ]; then
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
echo "Installing: $plugin_name"
|
||||
curl -L --silent --output ${plugin_dir}/${plugin_name}.hpi https://updates.jenkins-ci.org/latest/${plugin_name}.hpi
|
||||
return 0
|
||||
}
|
||||
|
||||
# Install plugin.
|
||||
for plugin in $*
|
||||
do
|
||||
installPlugin "$plugin"
|
||||
done
|
||||
|
||||
changed=1
|
||||
maxloops=5
|
||||
|
||||
# Install all dependencies.
|
||||
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
|
||||
# if installPlugin returns 1 then 'changed' stays as is. (it means that the whole jenkins plugins state is not changed and in fact, nothing installed)
|
||||
# if installPlugin returns 0 then changed=1
|
||||
installPlugin "$plugin" 1 && changed=1
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
# Fixing permissions.
|
||||
chown -R ${owner} ${plugin_dir}
|
||||
|
||||
# Restart Jenkins.
|
||||
service jenkins restart
|
@ -10,4 +10,8 @@ node default {
|
||||
ssl_key_file => '/etc/ssl/private/ssl-cert-snakeoil.key',
|
||||
manage_jenkins_jobs => false,
|
||||
}
|
||||
}
|
||||
|
||||
package { 'unzip':
|
||||
ensure => present
|
||||
}
|
||||
}
|
||||
|
@ -1,26 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Plugin names are sorted in dependency order.
|
||||
# The first ones doesn't have any dependencies while
|
||||
# the next ones have the previous ones as the dependencies.
|
||||
plugin_list="icon-shim
|
||||
mailer
|
||||
scm-api
|
||||
token-macro
|
||||
parameterized-trigger
|
||||
junit
|
||||
script-security
|
||||
credentials
|
||||
ssh-credentials
|
||||
git-client
|
||||
matrix-project
|
||||
git"
|
||||
|
||||
for plugin in $plugin_list
|
||||
do
|
||||
curl -L https://updates.jenkins-ci.org/latest/$plugin.hpi > /var/lib/jenkins/plugins/$plugin.hpi
|
||||
chown jenkins:jenkins /var/lib/jenkins/plugins/$plugin.hpi
|
||||
chmod 0644 /var/lib/jenkins/plugins/$plugin.hpi
|
||||
done
|
||||
|
||||
service jenkins restart
|
Loading…
x
Reference in New Issue
Block a user