blob: d940041f8fbf8355ec25d02886946bc69e7ef409 [file] [log] [blame]
Lusheng Ji487c0cc2017-08-22 21:44:29 -07001#!/bin/bash
2
Lusheng Ji16948022017-09-11 23:38:09 +00003# ================================================================================
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
21set -ex
22
23
Lusheng Ji487c0cc2017-08-22 21:44:29 -070024echo "running script: [$0] for module [$1] at stage [$2]"
25
Lusheng Ji16948022017-09-11 23:38:09 +000026MVN_PROJECT_MODULEID="$1"
27MVN_PHASE="$2"
Lusheng Ji487c0cc2017-08-22 21:44:29 -070028
Lusheng Ji487c0cc2017-08-22 21:44:29 -070029
Lusheng Ji16948022017-09-11 23:38:09 +000030PROJECT_ROOT=$(dirname $0)
31
32FQDN="${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
44echo "MVN_DEPLOYMENT_TYPE is [$MVN_DEPLOYMENT_TYPE]"
45
46
47TIMESTAMP=$(date +%C%y%m%dT%H%M%S)
48
49# expected environment variables
Lusheng Ji487c0cc2017-08-22 21:44:29 -070050if [ -z "${MVN_NEXUSPROXY}" ]; then
51 echo "MVN_NEXUSPROXY environment variable not set. Cannot proceed"
52 exit
53fi
Lusheng Ji16948022017-09-11 23:38:09 +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
61if [ -z "$SETTINGS_FILE" ]; then
62 echo "SETTINGS_FILE environment variable not set. Cannot proceed"
63 exit
64fi
65
Lusheng Ji487c0cc2017-08-22 21:44:29 -070066
67
Lusheng Ji16948022017-09-11 23:38:09 +000068# mvn phase in life cycle
Lusheng Ji487c0cc2017-08-22 21:44:29 -070069MVN_PHASE="$2"
70
Lusheng Ji16948022017-09-11 23:38:09 +000071
72echo "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]"
83echo "MVN_DOCKERREGISTRY_DAILY is [$MVN_DOCKERREGISTRY_DAILY]"
84echo "MVN_DOCKERREGISTRY_RELEASE is [$MVN_DOCKERREGISTRY_RELEASE]"
85
86
87source "${PROJECT_ROOT}"/mvn-phase-lib.sh
88
89
90# Customize the section below for each project
Lusheng Ji487c0cc2017-08-22 21:44:29 -070091case $MVN_PHASE in
92clean)
93 echo "==> clean phase script"
Lusheng Ji16948022017-09-11 23:38:09 +000094 clean_templated_files
95 clean_tox_files
96 rm -rf ./venv-* ./*.wgn ./site
Lusheng Ji487c0cc2017-08-22 21:44:29 -070097 ;;
98generate-sources)
99 echo "==> generate-sources phase script"
Lusheng Ji16948022017-09-11 23:38:09 +0000100 expand_templates
Lusheng Ji487c0cc2017-08-22 21:44:29 -0700101 ;;
102compile)
103 echo "==> compile phase script"
104 ;;
105test)
106 echo "==> test phase script"
107 ;;
108package)
109 echo "==> package phase script"
110 ;;
111install)
112 echo "==> install phase script"
113 ;;
114deploy)
115 echo "==> deploy phase script"
Lusheng Ji16948022017-09-11 23:38:09 +0000116
117 case $MVN_PROJECT_MODULEID in
118 platformdoc)
119 set -x
120 CURDIR=$(pwd)
121 virtualenv ./venv-doc
122 source ./venv-doc/bin/activate
123 pip install --upgrade pip
124 pip install --upgrade mkdocs mkdocs-material
125 pip freeze
126
127 mkdocs build
128 build_and_push_docker
129 deactivate
130 rm -rf ./venv-doc
131
132 # build docker image from Docker file (under module dir) and push to registry
133 build_and_push_docker
134 ;;
135 *)
136 echo "====> unknown mvn project module"
137 ;;
138 esac
139
Lusheng Ji487c0cc2017-08-22 21:44:29 -0700140 ;;
141*)
142 echo "==> unprocessed phase"
143 ;;
144esac
145