blob: 7d432afa4c233d02e4aa59cfef51e4a40c7aca1e [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
Andrew Gauld373f0f32018-02-21 11:14:46 -050036export SETTINGS_FILE=${SETTINGS_FILE:-$HOME/.m2/settings.xml}
Lusheng Ji88648fc2017-09-20 02:18:20 +000037
Lusheng Ji00444ab2017-10-13 17:39:45 +000038set +e
Lusheng Ji7ed33762018-03-05 08:10:18 -050039source "${PROJECT_ROOT}"/scripts/mvn-phase-lib.sh
Lusheng Ji88648fc2017-09-20 02:18:20 +000040
Lusheng Ji5bc79f42017-08-29 14:20:46 +000041
Tony Hansen4b747742017-09-19 05:04:05 +000042# This is the base for where "deploy" will upload
43# MVN_NEXUSPROXY is set in the pom.xml
44REPO=$MVN_NEXUSPROXY/content/sites/raw/$MVN_PROJECT_GROUPID
45
46TIMESTAMP=$(date +%C%y%m%dT%H%M%S)
Lusheng Ji5bc79f42017-08-29 14:20:46 +000047export BUILD_NUMBER="${TIMESTAMP}"
48
Lusheng Ji5bc79f42017-08-29 14:20:46 +000049
Tony Hansen4b747742017-09-19 05:04:05 +000050shift 2
Lusheng Ji5bc79f42017-08-29 14:20:46 +000051
52case $MVN_PHASE in
53clean)
54 echo "==> clean phase script"
Lusheng Ji88648fc2017-09-20 02:18:20 +000055 case $MVN_PROJECT_MODULEID in
Lusheng Ji88648fc2017-09-20 02:18:20 +000056 *)
57 clean_templated_files
58 clean_tox_files
59 rm -rf ./venv-* ./*.wgn ./site ./coverage.xml ./xunit-results.xml
60 ;;
61 esac
Lusheng Ji5bc79f42017-08-29 14:20:46 +000062 ;;
63generate-sources)
64 echo "==> generate-sources phase script"
Lusheng Ji88648fc2017-09-20 02:18:20 +000065 case $MVN_PROJECT_MODULEID in
Lusheng Ji88648fc2017-09-20 02:18:20 +000066 *)
67 expand_templates
68 ;;
69 esac
Lusheng Ji5bc79f42017-08-29 14:20:46 +000070 ;;
71compile)
72 echo "==> compile phase script"
Lusheng Ji88648fc2017-09-20 02:18:20 +000073 case $MVN_PROJECT_MODULEID in
Lusheng Ji88648fc2017-09-20 02:18:20 +000074 *)
75 ;;
76 esac
Lusheng Ji5bc79f42017-08-29 14:20:46 +000077 ;;
78test)
79 echo "==> test phase script"
Lusheng Ji88648fc2017-09-20 02:18:20 +000080 case $MVN_PROJECT_MODULEID in
Lusheng Ji88648fc2017-09-20 02:18:20 +000081 *)
Andrew Gauld373f0f32018-02-21 11:14:46 -050082 if [ -f tox.ini ]
83 then
84 set -e
85 run_tox_test
86 set +e
87 fi
Lusheng Ji88648fc2017-09-20 02:18:20 +000088 ;;
89 esac
Lusheng Ji5bc79f42017-08-29 14:20:46 +000090 ;;
91package)
92 echo "==> package phase script"
Lusheng Ji88648fc2017-09-20 02:18:20 +000093 case $MVN_PROJECT_MODULEID in
Lusheng Ji310c9c12017-10-13 21:45:18 +000094 scripts)
95 upload_files_of_extension "sh" "$MVN_PROJECT_MODULEID"
96 ;;
Lusheng Ji88648fc2017-09-20 02:18:20 +000097 *)
98 ;;
99 esac
Lusheng Ji5bc79f42017-08-29 14:20:46 +0000100 ;;
101install)
102 echo "==> install phase script"
Lusheng Ji88648fc2017-09-20 02:18:20 +0000103 case $MVN_PROJECT_MODULEID in
Lusheng Ji88648fc2017-09-20 02:18:20 +0000104 *)
105 ;;
106 esac
Lusheng Ji5bc79f42017-08-29 14:20:46 +0000107 ;;
108deploy)
109 echo "==> deploy phase script"
Lusheng Ji88648fc2017-09-20 02:18:20 +0000110 case $MVN_PROJECT_MODULEID in
Lusheng Ji00444ab2017-10-13 17:39:45 +0000111 scripts)
112 upload_files_of_extension "sh" "$MVN_PROJECT_MODULEID"
113 ;;
Lusheng Ji88648fc2017-09-20 02:18:20 +0000114 *)
Lusheng Jia7a58372017-09-20 03:57:14 +0000115 # uncomment after we figure out how to use pypi. this command expects that the credentials are passed in
116 # settings.xml, and the URL and serverid are passed in from either oparent or dcaegen2's root pom
117 # before this is ready comment below out
118 #generate_pypirc_then_publish
Lusheng Ji88648fc2017-09-20 02:18:20 +0000119 ;;
120 esac
Lusheng Ji5bc79f42017-08-29 14:20:46 +0000121 ;;
122*)
123 echo "==> unprocessed phase"
124 ;;
125esac
126