blob: afbe9610edd5373a3be3a5b0f3739d5911848c66 [file] [log] [blame]
Lusheng Jic8bd8912017-08-29 14:11:28 +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
Lusheng Jiefb18512017-09-11 18:14:56 +000021set -ex
22
Lusheng Jic8bd8912017-08-29 14:11:28 +000023
24echo "running script: [$0] for module [$1] at stage [$2]"
25
Lusheng Ji43658612017-09-08 19:12:45 +000026MVN_PROJECT_MODULEID="$1"
Lusheng Ji98be1432017-09-06 19:38:42 +000027MVN_PHASE="$2"
28
Lusheng Ji43658612017-09-08 19:12:45 +000029
Lusheng Jiab7883e2017-10-10 14:22:53 +000030PROJECT_ROOT=$(dirname $0)
31
Lusheng Ji43658612017-09-08 19:12:45 +000032FQDN="${MVN_PROJECT_GROUPID}.${MVN_PROJECT_ARTIFACTID}"
33if [ "$MVN_PROJECT_MODULEID" == "__" ]; then
34 MVN_PROJECT_MODULEID=""
35fi
36
37if [[ "$MVN_PROJECT_VERSION" == *SNAPSHOT ]]; then
38 echo "=> for SNAPSHOT artifact build"
39 MVN_DEPLOYMENT_TYPE='SNAPSHOT'
40else
41 echo "=> for STAGING/RELEASE artifact build"
42 MVN_DEPLOYMENT_TYPE='STAGING'
43fi
Lusheng Jiefb18512017-09-11 18:14:56 +000044echo "MVN_DEPLOYMENT_TYPE is [$MVN_DEPLOYMENT_TYPE]"
Lusheng Ji43658612017-09-08 19:12:45 +000045
46
47TIMESTAMP=$(date +%C%y%m%dT%H%M%S)
48
49# expected environment variables
50if [ -z "${MVN_NEXUSPROXY}" ]; then
51 echo "MVN_NEXUSPROXY environment variable not set. Cannot proceed"
52 exit
53fi
Lusheng Ji43658612017-09-08 19:12:45 +000054MVN_NEXUSPROXY_HOST=$(echo "$MVN_NEXUSPROXY" |cut -f3 -d'/' | cut -f1 -d':')
55echo "=> Nexus Proxy at $MVN_NEXUSPROXY_HOST, $MVN_NEXUSPROXY"
56
57if [ -z "$WORKSPACE" ]; then
58 WORKSPACE=$(pwd)
59fi
60
Lusheng Jiab7883e2017-10-10 14:22:53 +000061if [ -z "$SETTINGS_FILE" ]; then
62 echo "SETTINGS_FILE environment variable not set. Cannot proceed"
63 exit
64fi
65
66
67
Lusheng Ji43658612017-09-08 19:12:45 +000068# mvn phase in life cycle
69MVN_PHASE="$2"
70
71
Lusheng Ji98be1432017-09-06 19:38:42 +000072echo "MVN_PROJECT_MODULEID is [$MVN_PROJECT_MODULEID]"
73echo "MVN_PHASE is [$MVN_PHASE]"
74echo "MVN_PROJECT_GROUPID is [$MVN_PROJECT_GROUPID]"
75echo "MVN_PROJECT_ARTIFACTID is [$MVN_PROJECT_ARTIFACTID]"
76echo "MVN_PROJECT_VERSION is [$MVN_PROJECT_VERSION]"
77echo "MVN_NEXUSPROXY is [$MVN_NEXUSPROXY]"
78echo "MVN_RAWREPO_BASEURL_UPLOAD is [$MVN_RAWREPO_BASEURL_UPLOAD]"
79echo "MVN_RAWREPO_BASEURL_DOWNLOAD is [$MVN_RAWREPO_BASEURL_DOWNLOAD]"
80MVN_RAWREPO_HOST=$(echo "$MVN_RAWREPO_BASEURL_UPLOAD" | cut -f3 -d'/' |cut -f1 -d':')
81echo "MVN_RAWREPO_HOST is [$MVN_RAWREPO_HOST]"
82echo "MVN_RAWREPO_SERVERID is [$MVN_RAWREPO_SERVERID]"
Lusheng Jiab7883e2017-10-10 14:22:53 +000083echo "MVN_DOCKERREGISTRY_SNAPSHOT is [$MVN_DOCKERREGISTRY_SNAPSHOT]"
Lusheng Ji98be1432017-09-06 19:38:42 +000084echo "MVN_DOCKERREGISTRY_RELEASE is [$MVN_DOCKERREGISTRY_RELEASE]"
Lusheng Jiab7883e2017-10-10 14:22:53 +000085echo "MVN_DOCKERREGISTRY_PUBLIC is [$MVN_DOCKERREGISTRY_PUBLIC]"
Tony Hansenffa416d2017-10-24 19:35:57 +000086echo "HOME is [$HOME]"
87echo "PROJECT_ROOT is [$PROJECT_ROOT]"
Lusheng Jiefb18512017-09-11 18:14:56 +000088
Lusheng Jiab7883e2017-10-10 14:22:53 +000089source "${PROJECT_ROOT}"/mvn-phase-lib.sh
Lusheng Ji43658612017-09-08 19:12:45 +000090
91
Lusheng Jiefb18512017-09-11 18:14:56 +000092# Customize the section below for each project
Lusheng Ji43658612017-09-08 19:12:45 +000093case $MVN_PHASE in
94clean)
95 echo "==> clean phase script"
Lusheng Jiefb18512017-09-11 18:14:56 +000096 clean_templated_files
Lusheng Jiab7883e2017-10-10 14:22:53 +000097 clean_tox_files
98 rm -rf ./venv-* ./*.wgn ./site
Lusheng Ji43658612017-09-08 19:12:45 +000099 ;;
100generate-sources)
101 echo "==> generate-sources phase script"
102 expand_templates
103 ;;
104compile)
105 echo "==> compile phase script"
106 ;;
107test)
108 echo "==> test phase script"
Tony Hansen1d013672017-10-06 21:01:05 +0000109 test_templates
Lusheng Ji43658612017-09-08 19:12:45 +0000110 ;;
111package)
112 echo "==> package phase script"
Lusheng Ji43658612017-09-08 19:12:45 +0000113 ;;
114install)
115 echo "==> install phase script"
116 ;;
117deploy)
118 echo "==> deploy phase script"
Lusheng Jib004cbc2017-10-13 15:59:06 +0000119 if [ -z "$MVN_PROJECT_MODULEID" ]; then
120 upload_files_of_extension yaml
121 else
122 upload_files_of_extension yaml "$MVN_PROJECT_MODULEID"
123 fi
Lusheng Jic8bd8912017-08-29 14:11:28 +0000124 ;;
125*)
126 echo "==> unprocessed phase"
127 ;;
128esac
129