Turn on multi-os merge jobs
[ci-management.git] / jjb / vpp / include-raw-vpp-maven-push.sh
1 #!/bin/bash
2
3 # Determine the path to maven
4 if [ -z "${MAVEN_SELECTOR}" ]; then
5     echo "ERROR: No Maven install detected!"
6     exit 1
7 fi
8
9 MVN="${HOME}/tools/hudson.tasks.Maven_MavenInstallation/${MAVEN_SELECTOR}/bin/mvn"
10 GROUP_ID="io.fd.${PROJECT}"
11 BASEURL="${NEXUSPROXY}/content/repositories/fd.io."
12 BASEREPOID='fdio-'
13
14 # find the files
15 JARS=$(find . -type f -iname '*.jar')
16 DEBS=$(find . -type f -iname '*.deb')
17
18 function push_file ()
19 {
20     push_file=$1
21     repoId=$2
22     url=$3
23     version=$4
24     artifactId=$5
25     file_type=$6
26     classifier=$7
27
28     if [ "$classifier" ]; then
29         d_classifier="-Dclassifier=$7"
30     fi
31
32     # Disable checks for doublequote to prevent glob / splitting
33     # shellcheck disable=SC2086
34     $MVN org.apache.maven.plugins:maven-deploy-plugin:deploy-file \
35         -Dfile=$push_file -DrepositoryId=$repoId \
36         -Durl=$url -DgroupId=$GROUP_ID \
37         -Dversion=$version -DartifactId=$artifactId \
38         -Dtype=$file_type $d_classifier\
39         -gs $GLOBAL_SETTINGS_FILE -s $SETTINGS_FILE
40
41     # make sure the script bombs if we fail an upload
42     if [ "$?" != '0' ]; then
43         echo "ERROR: There was an error with the upload"
44         exit 1
45     fi
46 }
47
48 function push_jar ()
49 {
50     jarfile=$1
51     repoId="${BASEREPOID}snapshot"
52     url="${BASEURL}snapshot"
53
54     basefile=$(basename -s .jar "$jarfile")
55     artifactId=$(echo "$basefile" | cut -f 1 -d '-')
56     version=$(echo "$basefile" | cut -f 2 -d '-')
57
58     push_file "$jarfile" "$repoId" "$url" "${version}-SNAPSHOT" "$artifactId" jar
59 }
60
61 function push_deb ()
62 {
63     debfile=$1
64     repoId="${BASEREPOID}dev"
65     url="${BASEURL}dev"
66
67     basefile=$(basename -s .deb "$debfile")
68     artifactId=$(echo "$basefile" | cut -f 1 -d '_')
69     version=$(echo "$basefile" | cut -f 2- -d '_')
70
71     push_file "$debfile" "$repoId" "$url" "$version" "$artifactId" deb
72 }
73 if [ ${OS} == "ubuntu1404" ]; then
74     for i in $JARS
75     do
76         push_jar "$i"
77     done
78
79     for i in $DEBS
80     do
81         push_deb "$i"
82     done
83 fi
84 # vim: ts=4 sw=4 sts=4 et ft=sh :