fix download failure detection
and fallback to `-plugin` for unconventional plugins
diff --git a/install-plugins.sh b/install-plugins.sh
index d6ac4cc..1bce1bf 100755
--- a/install-plugins.sh
+++ b/install-plugins.sh
@@ -5,9 +5,8 @@
# FROM jenkins
# RUN install-plugins.sh docker-slaves github-branch-source
-set -e
-REF=/usr/share/jenkins/ref/plugins
+REF=${REF:-/usr/share/jenkins/ref/plugins}
mkdir -p "$REF"
function download() {
@@ -15,7 +14,7 @@
if [[ ! -f "${plugin}.hpi" ]]; then
- url="${JENKINS_UC}/latest/${plugin}.hpi"
+ local url="${JENKINS_UC}/latest/${plugin}.hpi"
echo "download plugin : $plugin from $url"
curl -s -f -L "$url" -o "${plugin}.hpi"
@@ -23,7 +22,9 @@
then
# some plugin don't follow the rules about artifact ID
# typically: docker-plugin
- curl -s -f -L "$url" -o "${plugin}-plugin.hpi"
+ local url="${JENKINS_UC}/latest/${plugin}-plugin.hpi"
+ echo "download plugin : $plugin from $url"
+ curl -s -f -L "${url}" -o "${plugin}.hpi"
if [[ $? -ne 0 ]]
then
>&2 echo "failed to download plugin ${plugin}"
@@ -42,7 +43,7 @@
function resolveDependencies() {
local plugin="$1"; shift
- dependencies=`jrunscript -e '\
+ local dependencies=`jrunscript -e '\
java.lang.System.out.println(\
new java.util.jar.JarFile("'${plugin}.hpi'")\
.getManifest()\
@@ -58,15 +59,14 @@
echo " > depends on ${dependencies}"
IFS=',' read -a array <<< "${dependencies}"
-
for d in "${array[@]}"
do
- plugin=$(echo $d | cut -d':' -f1 -)
+ local p=$(echo $d | cut -d':' -f1 -)
if [[ $d == *"resolution:=optional"* ]]
then
- echo "skipping optional dependency $plugin"
+ echo "skipping optional dependency $p"
else
- download "$plugin"
+ download "$p"
fi
done
touch "${plugin}.resolved"