blob: ab9605cfb8c83e4c784a366085fcbee8d2f87547 [file] [log] [blame]
Lusheng Jif487f062017-08-29 14:18:43 +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 Jife9c74b2017-09-12 02:16:34 +000021set -ex
22
Lusheng Jif487f062017-08-29 14:18:43 +000023echo "running script: [$0] for module [$1] at stage [$2]"
24
Lusheng Jife9c74b2017-09-12 02:16:34 +000025MVN_PROJECT_MODULEID="$1"
26MVN_PHASE="$2"
Lusheng Jife9c74b2017-09-12 02:16:34 +000027PROJECT_ROOT=$(dirname $0)
28
Lusheng Jife9c74b2017-09-12 02:16:34 +000029# expected environment variables
Lusheng Jif487f062017-08-29 14:18:43 +000030if [ -z "${MVN_NEXUSPROXY}" ]; then
31 echo "MVN_NEXUSPROXY environment variable not set. Cannot proceed"
Lusheng Ji7e99e112018-02-19 23:57:20 -050032 exit 1
Lusheng Jif487f062017-08-29 14:18:43 +000033fi
Lusheng Jife9c74b2017-09-12 02:16:34 +000034if [ -z "$SETTINGS_FILE" ]; then
35 echo "SETTINGS_FILE environment variable not set. Cannot proceed"
Lusheng Ji7e99e112018-02-19 23:57:20 -050036 exit 2
Lusheng Jife9c74b2017-09-12 02:16:34 +000037fi
Lusheng Ji7e99e112018-02-19 23:57:20 -050038
39set +e
Lusheng Ji30a81ab2018-04-02 22:57:44 -040040RELEASE_TAG=${MVN_RELEASE_TAG:-R2}
41if [ "$RELEASE_TAG" != "R1" ]; then
42 RELEASE_TAGGED_DIR="${RELEASE_TAG}/"
43else
44 RELEASE_TAGGED_DIR="releases"
Lusheng Ji7e99e112018-02-19 23:57:20 -050045fi
Lusheng Ji30a81ab2018-04-02 22:57:44 -040046if ! wget -O ${PROJECT_ROOT}/mvn-phase-lib.sh \
47 "$MVN_RAWREPO_BASEURL_DOWNLOAD"/org.onap.dcaegen2.utils/${RELEASE_TAGGED_DIR}scripts/mvn-phase-lib.sh; then
48 echo "Fail to download mvn-phase-lib.sh"
49 exit 1
50fi
51
Lusheng Ji7e99e112018-02-19 23:57:20 -050052source "${PROJECT_ROOT}"/mvn-phase-lib.sh
Lusheng Jife9c74b2017-09-12 02:16:34 +000053
54
Lusheng Ji7e99e112018-02-19 23:57:20 -050055# This is the base for where "deploy" will upload
56# MVN_NEXUSPROXY is set in the pom.xml
57REPO=$MVN_NEXUSPROXY/content/sites/raw/$MVN_PROJECT_GROUPID
Lusheng Jif487f062017-08-29 14:18:43 +000058
Lusheng Ji7e99e112018-02-19 23:57:20 -050059TIMESTAMP=$(date +%C%y%m%dT%H%M%S)
60export BUILD_NUMBER="${TIMESTAMP}"
Lusheng Jife9c74b2017-09-12 02:16:34 +000061
Lusheng Ji7e99e112018-02-19 23:57:20 -050062shift 2
Lusheng Jife9c74b2017-09-12 02:16:34 +000063
64# Customize the section below for each project
Lusheng Jif487f062017-08-29 14:18:43 +000065case $MVN_PHASE in
66clean)
67 echo "==> clean phase script"
Lusheng Jife9c74b2017-09-12 02:16:34 +000068 clean_templated_files
69 clean_tox_files
Lusheng Ji7e99e112018-02-19 23:57:20 -050070 rm -rf ./venv-* ./*.wgn ./site logs
Lusheng Jif487f062017-08-29 14:18:43 +000071 ;;
72generate-sources)
73 echo "==> generate-sources phase script"
Lusheng Jife9c74b2017-09-12 02:16:34 +000074 expand_templates
Lusheng Jif487f062017-08-29 14:18:43 +000075 ;;
76compile)
77 echo "==> compile phase script"
78 ;;
79test)
80 echo "==> test phase script"
Lusheng Ji7e99e112018-02-19 23:57:20 -050081 mkdir logs
82 run_tox_test
Lusheng Jif487f062017-08-29 14:18:43 +000083 ;;
84package)
85 echo "==> package phase script"
86 ;;
87install)
88 echo "==> install phase script"
89 ;;
90deploy)
91 echo "==> deploy phase script"
Lusheng Jife9c74b2017-09-12 02:16:34 +000092 # below segments are example of how to deploy various artifacts
93 # copy the ones suitable for your repo, and remove the "if false" statement
94
95 # build docker image from Docker file (under root of repo) and push to registry
96 build_and_push_docker
Lusheng Jif487f062017-08-29 14:18:43 +000097 ;;
98*)
99 echo "==> unprocessed phase"
100 ;;
101esac
102