blob: 094e642b1c149bbeed2723101f29da43b5588699 [file] [log] [blame]
Lusheng Ji5bc79f42017-08-29 14:20:46 +00001#!/bin/bash
2
3# ================================================================================
4# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
5# ================================================================================
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17# ============LICENSE_END=========================================================
18#
19# ECOMP is a trademark and service mark of AT&T Intellectual Property.
20
21
Lusheng Ji88648fc2017-09-20 02:18:20 +000022set -ex
23
24
Lusheng Ji5bc79f42017-08-29 14:20:46 +000025echo "running script: [$0] for module [$1] at stage [$2]"
26
Lusheng Ji88648fc2017-09-20 02:18:20 +000027MVN_PROJECT_MODULEID="$1"
28MVN_PHASE="$2"
29PROJECT_ROOT=$(dirname $0)
30
31# expected environment variables
32if [ -z "${MVN_NEXUSPROXY}" ]; then
33 echo "MVN_NEXUSPROXY environment variable not set. Cannot proceed"
34 exit 1
35fi
36if [ -z "$SETTINGS_FILE" ]; then
37 echo "SETTINGS_FILE environment variable not set. Cannot proceed"
38 exit 2
39fi
40
41
42source "${PROJECT_ROOT}"/mvn-phase-lib.sh
43
Lusheng Ji5bc79f42017-08-29 14:20:46 +000044
Tony Hansen4b747742017-09-19 05:04:05 +000045# This is the base for where "deploy" will upload
46# MVN_NEXUSPROXY is set in the pom.xml
47REPO=$MVN_NEXUSPROXY/content/sites/raw/$MVN_PROJECT_GROUPID
48
49TIMESTAMP=$(date +%C%y%m%dT%H%M%S)
Lusheng Ji5bc79f42017-08-29 14:20:46 +000050export BUILD_NUMBER="${TIMESTAMP}"
51
Lusheng Ji5bc79f42017-08-29 14:20:46 +000052
Tony Hansen4b747742017-09-19 05:04:05 +000053shift 2
Lusheng Ji5bc79f42017-08-29 14:20:46 +000054
55case $MVN_PHASE in
56clean)
57 echo "==> clean phase script"
Lusheng Ji88648fc2017-09-20 02:18:20 +000058 case $MVN_PROJECT_MODULEID in
59 check-blueprint-vs-input | repackage)
60 if [ -f makefile -o -f Makefile ];then make clean; else :; fi
61 ;;
62 *)
63 clean_templated_files
64 clean_tox_files
65 rm -rf ./venv-* ./*.wgn ./site ./coverage.xml ./xunit-results.xml
66 ;;
67 esac
Lusheng Ji5bc79f42017-08-29 14:20:46 +000068 ;;
69generate-sources)
70 echo "==> generate-sources phase script"
Lusheng Ji88648fc2017-09-20 02:18:20 +000071 case $MVN_PROJECT_MODULEID in
72 check-blueprint-vs-input | repackage)
73 if [ -f makefile -o -f Makefile ];then make generate-sources; else :; fi
74 ;;
75 *)
76 expand_templates
77 ;;
78 esac
Lusheng Ji5bc79f42017-08-29 14:20:46 +000079 ;;
80compile)
81 echo "==> compile phase script"
Lusheng Ji88648fc2017-09-20 02:18:20 +000082 case $MVN_PROJECT_MODULEID in
83 check-blueprint-vs-input | repackage)
84 if [ -f makefile -o -f Makefile ];then make compile; else :; fi
85 ;;
86 *)
87 ;;
88 esac
Lusheng Ji5bc79f42017-08-29 14:20:46 +000089 ;;
90test)
91 echo "==> test phase script"
Lusheng Ji88648fc2017-09-20 02:18:20 +000092 case $MVN_PROJECT_MODULEID in
93 check-blueprint-vs-input | repackage)
94 if [ -f makefile -o -f Makefile ];then make test; else :; fi
95 ;;
96 *)
97 set +e
98 run_tox_test
99 set -e
100 ;;
101 esac
Lusheng Ji5bc79f42017-08-29 14:20:46 +0000102 ;;
103package)
104 echo "==> package phase script"
Lusheng Ji88648fc2017-09-20 02:18:20 +0000105 case $MVN_PROJECT_MODULEID in
106 check-blueprint-vs-input | repackage)
107 if [ -f makefile -o -f Makefile ];then make package; else :; fi
108 ;;
109 *)
110 ;;
111 esac
Lusheng Ji5bc79f42017-08-29 14:20:46 +0000112 ;;
113install)
114 echo "==> install phase script"
Lusheng Ji88648fc2017-09-20 02:18:20 +0000115 case $MVN_PROJECT_MODULEID in
116 check-blueprint-vs-input | repackage)
117 if [ -f makefile -o -f Makefile ];then make install; else :; fi
118 ;;
119 *)
120 ;;
121 esac
Lusheng Ji5bc79f42017-08-29 14:20:46 +0000122 ;;
123deploy)
124 echo "==> deploy phase script"
Lusheng Ji88648fc2017-09-20 02:18:20 +0000125 case $MVN_PROJECT_MODULEID in
126 check-blueprint-vs-input | repackage)
127 if [ -f makefile -o -f Makefile ];then make deploy
128 else
129 # Upload all files (listed as additional deployment arguments) to Nexus
130 # additional
131 for artifact
132 do
133 upload_raw_file $artifact
134 done
135 set +e +x
136 fi
137 ;;
138 *)
139 generate_pypirc_then_publish
140 ;;
141 esac
Lusheng Ji5bc79f42017-08-29 14:20:46 +0000142 ;;
143*)
144 echo "==> unprocessed phase"
145 ;;
146esac
147