blob: 750eb5cd2089fee73e73e5a67117ca4c294cc8b4 [file] [log] [blame]
Nicolas De Loofdfe81a32016-05-28 17:26:01 +02001#! /bin/bash
Nicolas De Loof0ef5a622016-05-27 19:14:29 +02002
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
Nicolas De Loofdfe81a32016-05-28 17:26:01 +020026 dependencies=`jrunscript -e '\
27 java.lang.System.out.println(\
28 new java.util.jar.JarFile("'${plugin}.hpi'")\
29 .getManifest()\
30 .getMainAttributes()\
31 .getValue("Plugin-Dependencies")\
32 );'`
Nicolas De Loof0ef5a622016-05-27 19:14:29 +020033
34 if [[ "$dependencies" == "null" ]]; then
Nicolas De Loofdfe81a32016-05-28 17:26:01 +020035 echo " > plugin has no dependencies"
Nicolas De Loof0ef5a622016-05-27 19:14:29 +020036 return
37 fi
38
39 echo " > depends on ${dependencies}"
40
41 IFS=',' read -a array <<< "${dependencies}"
42
43 for d in "${array[@]}"
44 do
45 plugin=$(echo $d | cut -d':' -f1 -)
46 if [[ $d == *"resolution:=optional"* ]]
47 then
48 echo "skipping optional dependency $plugin"
49 else
50 download $plugin
51 fi
52 done
53}
54
55
Nicolas De Loofdfe81a32016-05-28 17:26:01 +020056shift
57for plugin in "$@"
58do
59 download $plugin
60done