blob: aa39ca9c1d5da616c3e0628354a3c86bab7579ef [file] [log] [blame]
Nicolas De Loof0ef5a622016-05-27 19:14:29 +02001#! /bin/sh
2
3function download() {
4 plugin=$1
5
6 if [[ ! -f ${plugin}.hpi ]]; then
7
8 url=http://updates.jenkins-ci.org/latest/${plugin}.hpi
9 echo "download plugin : $plugin from $url"
10
11 curl -s -f -L $url -o ${plugin}.hpi
12 if [[ $? -ne 0 ]]
13 then
14 >&2 echo "failed to download plugin ${plugin}"
15 exit -1
16 fi
17 else
18 echo "$plugin is allready downloaded."
19 fi
20 resolveDependencies $1
21}
22
23function resolveDependencies() {
24 plugin=$1
25
26 dependencies=`jrunscript -e 'java.lang.System.out.println(new java.util.jar.JarFile("'${plugin}.hpi'").getManifest().getMainAttributes().getValue("Plugin-Dependencies"));'`
27
28 if [[ "$dependencies" == "null" ]]; then
29 return
30 fi
31
32 echo " > depends on ${dependencies}"
33
34 IFS=',' read -a array <<< "${dependencies}"
35
36 for d in "${array[@]}"
37 do
38 plugin=$(echo $d | cut -d':' -f1 -)
39 if [[ $d == *"resolution:=optional"* ]]
40 then
41 echo "skipping optional dependency $plugin"
42 else
43 download $plugin
44 fi
45 done
46}
47
48
49download $1