Correct jjb and mvn parameters for honeycomb deployment
[ci-management.git] / jjb / scripts / maven_push_functions.sh
1 #!/bin/bash
2 set -xe -o pipefail
3 echo "*******************************************************************"
4 echo "* STARTING PUSH OF PACKAGES TO REPOS"
5 echo "* NOTHING THAT HAPPENS BELOW THIS POINT IS RELATED TO BUILD FAILURE"
6 echo "*******************************************************************"
7
8 # Determine the path to maven
9 if [ -z "${MAVEN_SELECTOR}" ]; then
10     echo "ERROR: No Maven install detected!"
11     exit 1
12 fi
13
14 MVN="${HOME}/tools/hudson.tasks.Maven_MavenInstallation/${MAVEN_SELECTOR}/bin/mvn"
15 GROUP_ID="io.fd.${PROJECT}"
16 BASEURL="${NEXUSPROXY}/content/repositories/fd.io."
17 BASEREPOID='fdio-'
18
19 function push_file ()
20 {
21     push_file=$1
22     repoId=$2
23     url=$3
24     version=$4
25     artifactId=$5
26     file_type=$6
27
28     if [ -n "$7" ]; then
29         d_classifier="-Dclassifier=$7"
30     fi
31
32     if [ ! -f "$push_file" ] ; then
33         echo "file for deployment does not exist: $push_file"
34         exit 1;
35     fi
36
37     # Disable checks for doublequote to prevent glob / splitting
38     # shellcheck disable=SC2086
39     $MVN org.apache.maven.plugins:maven-deploy-plugin:deploy-file \
40         -Dfile=$push_file -DrepositoryId=$repoId \
41         -Durl=$url -DgroupId=$GROUP_ID \
42         -Dversion=$version -DartifactId=$artifactId \
43         -Dtype=$file_type $d_classifier\
44         -gs $GLOBAL_SETTINGS_FILE -s $SETTINGS_FILE
45
46     # make sure the script bombs if we fail an upload
47     if [ "$?" != '0' ]; then
48         echo "ERROR: There was an error with the upload"
49         exit 1
50     fi
51 }
52
53 function push_jar ()
54 {
55     jarfile=$1
56     repoId="${BASEREPOID}snapshot"
57     url="${BASEURL}snapshot"
58
59     basefile=$(basename -s .jar "$jarfile")
60     artifactId=$(echo "$basefile" | cut -f 1 -d '-')
61     version=$(echo "$basefile" | cut -f 2 -d '-')
62
63     push_file "$jarfile" "$repoId" "$url" "${version}-SNAPSHOT" "$artifactId" jar
64 }
65
66 function push_deb ()
67 {
68     debfile=$1
69     repoId="fd.io.${REPO_NAME}"
70     url="${BASEURL}${REPO_NAME}"
71
72     basefile=$(basename -s .deb "$debfile")
73     artifactId=$(echo "$basefile" | cut -f 1 -d '_')
74     version=$(echo "$basefile" | cut -f 2- -d '_')
75
76     push_file "$debfile" "$repoId" "$url" "$version" "$artifactId" deb
77 }
78
79 function push_rpm ()
80 {
81     rpmfile=$1
82     repoId="fd.io.${REPO_NAME}"
83     url="${BASEURL}${REPO_NAME}"
84
85     if grep -qE '\.s(rc\.)?rpm' <<<"$rpmfile"
86     then
87         rpmrelease=$(rpm -qp --queryformat="%{release}.src" "$rpmfile")
88     else
89         rpmrelease=$(rpm -qp --queryformat="%{release}.%{arch}" "$rpmfile")
90     fi
91     artifactId=$(rpm -qp --queryformat="%{name}" "$rpmfile")
92     version=$(rpm -qp --queryformat="%{version}" "$rpmfile")
93     push_file "$rpmfile" "$repoId" "$url" "${version}-${rpmrelease}" "$artifactId" rpm
94 }