Lusheng Ji | c8bd891 | 2017-08-29 14:11:28 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # ================================================================================ |
Jack Lucas | bad7720 | 2020-02-03 18:21:29 -0500 | [diff] [blame] | 4 | # Copyright (c) 2017-2020 AT&T Intellectual Property. All rights reserved. |
Lusheng Ji | c8bd891 | 2017-08-29 14:11:28 +0000 | [diff] [blame] | 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========================================================= |
Lusheng Ji | c8bd891 | 2017-08-29 14:11:28 +0000 | [diff] [blame] | 18 | |
Lusheng Ji | efb1851 | 2017-09-11 18:14:56 +0000 | [diff] [blame] | 19 | set -ex |
| 20 | |
Lusheng Ji | c8bd891 | 2017-08-29 14:11:28 +0000 | [diff] [blame] | 21 | |
| 22 | echo "running script: [$0] for module [$1] at stage [$2]" |
| 23 | |
Lusheng Ji | 4365861 | 2017-09-08 19:12:45 +0000 | [diff] [blame] | 24 | MVN_PROJECT_MODULEID="$1" |
Lusheng Ji | 98be143 | 2017-09-06 19:38:42 +0000 | [diff] [blame] | 25 | MVN_PHASE="$2" |
| 26 | |
Lusheng Ji | 4365861 | 2017-09-08 19:12:45 +0000 | [diff] [blame] | 27 | |
Lusheng Ji | ab7883e | 2017-10-10 14:22:53 +0000 | [diff] [blame] | 28 | PROJECT_ROOT=$(dirname $0) |
| 29 | |
Lusheng Ji | 4365861 | 2017-09-08 19:12:45 +0000 | [diff] [blame] | 30 | FQDN="${MVN_PROJECT_GROUPID}.${MVN_PROJECT_ARTIFACTID}" |
| 31 | if [ "$MVN_PROJECT_MODULEID" == "__" ]; then |
| 32 | MVN_PROJECT_MODULEID="" |
| 33 | fi |
| 34 | |
| 35 | if [[ "$MVN_PROJECT_VERSION" == *SNAPSHOT ]]; then |
| 36 | echo "=> for SNAPSHOT artifact build" |
| 37 | MVN_DEPLOYMENT_TYPE='SNAPSHOT' |
| 38 | else |
| 39 | echo "=> for STAGING/RELEASE artifact build" |
| 40 | MVN_DEPLOYMENT_TYPE='STAGING' |
| 41 | fi |
Lusheng Ji | efb1851 | 2017-09-11 18:14:56 +0000 | [diff] [blame] | 42 | echo "MVN_DEPLOYMENT_TYPE is [$MVN_DEPLOYMENT_TYPE]" |
Lusheng Ji | 4365861 | 2017-09-08 19:12:45 +0000 | [diff] [blame] | 43 | |
| 44 | |
| 45 | TIMESTAMP=$(date +%C%y%m%dT%H%M%S) |
| 46 | |
| 47 | # expected environment variables |
| 48 | if [ -z "${MVN_NEXUSPROXY}" ]; then |
| 49 | echo "MVN_NEXUSPROXY environment variable not set. Cannot proceed" |
| 50 | exit |
| 51 | fi |
Lusheng Ji | 4365861 | 2017-09-08 19:12:45 +0000 | [diff] [blame] | 52 | MVN_NEXUSPROXY_HOST=$(echo "$MVN_NEXUSPROXY" |cut -f3 -d'/' | cut -f1 -d':') |
| 53 | echo "=> Nexus Proxy at $MVN_NEXUSPROXY_HOST, $MVN_NEXUSPROXY" |
| 54 | |
| 55 | if [ -z "$WORKSPACE" ]; then |
| 56 | WORKSPACE=$(pwd) |
| 57 | fi |
| 58 | |
Lusheng Ji | ab7883e | 2017-10-10 14:22:53 +0000 | [diff] [blame] | 59 | if [ -z "$SETTINGS_FILE" ]; then |
| 60 | echo "SETTINGS_FILE environment variable not set. Cannot proceed" |
| 61 | exit |
| 62 | fi |
Jack Lucas | bad7720 | 2020-02-03 18:21:29 -0500 | [diff] [blame] | 63 | |
Lusheng Ji | ab7883e | 2017-10-10 14:22:53 +0000 | [diff] [blame] | 64 | |
| 65 | |
Lusheng Ji | 4365861 | 2017-09-08 19:12:45 +0000 | [diff] [blame] | 66 | # mvn phase in life cycle |
| 67 | MVN_PHASE="$2" |
| 68 | |
| 69 | |
Lusheng Ji | 6ae6ef9 | 2018-03-18 23:21:25 -0400 | [diff] [blame] | 70 | echo "MVN_RELEASE_TAG is [$MVN_RELEASE_TAG]" |
Lusheng Ji | 98be143 | 2017-09-06 19:38:42 +0000 | [diff] [blame] | 71 | echo "MVN_PROJECT_MODULEID is [$MVN_PROJECT_MODULEID]" |
| 72 | echo "MVN_PHASE is [$MVN_PHASE]" |
| 73 | echo "MVN_PROJECT_GROUPID is [$MVN_PROJECT_GROUPID]" |
| 74 | echo "MVN_PROJECT_ARTIFACTID is [$MVN_PROJECT_ARTIFACTID]" |
| 75 | echo "MVN_PROJECT_VERSION is [$MVN_PROJECT_VERSION]" |
| 76 | echo "MVN_NEXUSPROXY is [$MVN_NEXUSPROXY]" |
| 77 | echo "MVN_RAWREPO_BASEURL_UPLOAD is [$MVN_RAWREPO_BASEURL_UPLOAD]" |
| 78 | echo "MVN_RAWREPO_BASEURL_DOWNLOAD is [$MVN_RAWREPO_BASEURL_DOWNLOAD]" |
| 79 | MVN_RAWREPO_HOST=$(echo "$MVN_RAWREPO_BASEURL_UPLOAD" | cut -f3 -d'/' |cut -f1 -d':') |
| 80 | echo "MVN_RAWREPO_HOST is [$MVN_RAWREPO_HOST]" |
| 81 | echo "MVN_RAWREPO_SERVERID is [$MVN_RAWREPO_SERVERID]" |
Lusheng Ji | ab7883e | 2017-10-10 14:22:53 +0000 | [diff] [blame] | 82 | echo "MVN_DOCKERREGISTRY_SNAPSHOT is [$MVN_DOCKERREGISTRY_SNAPSHOT]" |
Lusheng Ji | 98be143 | 2017-09-06 19:38:42 +0000 | [diff] [blame] | 83 | echo "MVN_DOCKERREGISTRY_RELEASE is [$MVN_DOCKERREGISTRY_RELEASE]" |
Lusheng Ji | ab7883e | 2017-10-10 14:22:53 +0000 | [diff] [blame] | 84 | echo "MVN_DOCKERREGISTRY_PUBLIC is [$MVN_DOCKERREGISTRY_PUBLIC]" |
Tony Hansen | ffa416d | 2017-10-24 19:35:57 +0000 | [diff] [blame] | 85 | echo "HOME is [$HOME]" |
| 86 | echo "PROJECT_ROOT is [$PROJECT_ROOT]" |
Lusheng Ji | efb1851 | 2017-09-11 18:14:56 +0000 | [diff] [blame] | 87 | |
vv770d | 1eeb2fe | 2020-10-01 21:53:11 +0000 | [diff] [blame] | 88 | MVN_RELEASE_TAG="${MVN_RELEASE_TAG:-R8}" |
Lusheng Ji | 6ae6ef9 | 2018-03-18 23:21:25 -0400 | [diff] [blame] | 89 | |
| 90 | |
| 91 | if ! wget -O ${PROJECT_ROOT}/mvn-phase-lib.sh \ |
| 92 | "$MVN_RAWREPO_BASEURL_DOWNLOAD"/org.onap.dcaegen2.utils/${MVN_RELEASE_TAG}/scripts/mvn-phase-lib.sh; then |
| 93 | echo "Fail to download mvn-phase-lib.sh" |
| 94 | exit 1 |
| 95 | fi |
| 96 | source "${PROJECT_ROOT}"/mvn-phase-lib.sh |
Lusheng Ji | 4365861 | 2017-09-08 19:12:45 +0000 | [diff] [blame] | 97 | |
| 98 | |
Lusheng Ji | efb1851 | 2017-09-11 18:14:56 +0000 | [diff] [blame] | 99 | # Customize the section below for each project |
Lusheng Ji | 4365861 | 2017-09-08 19:12:45 +0000 | [diff] [blame] | 100 | case $MVN_PHASE in |
| 101 | clean) |
| 102 | echo "==> clean phase script" |
Lusheng Ji | efb1851 | 2017-09-11 18:14:56 +0000 | [diff] [blame] | 103 | clean_templated_files |
Lusheng Ji | ab7883e | 2017-10-10 14:22:53 +0000 | [diff] [blame] | 104 | clean_tox_files |
| 105 | rm -rf ./venv-* ./*.wgn ./site |
Lusheng Ji | 4365861 | 2017-09-08 19:12:45 +0000 | [diff] [blame] | 106 | ;; |
| 107 | generate-sources) |
| 108 | echo "==> generate-sources phase script" |
| 109 | expand_templates |
| 110 | ;; |
| 111 | compile) |
| 112 | echo "==> compile phase script" |
| 113 | ;; |
| 114 | test) |
| 115 | echo "==> test phase script" |
Tony Hansen | 1d01367 | 2017-10-06 21:01:05 +0000 | [diff] [blame] | 116 | test_templates |
Lusheng Ji | 4365861 | 2017-09-08 19:12:45 +0000 | [diff] [blame] | 117 | ;; |
| 118 | package) |
| 119 | echo "==> package phase script" |
Lusheng Ji | 4365861 | 2017-09-08 19:12:45 +0000 | [diff] [blame] | 120 | ;; |
| 121 | install) |
| 122 | echo "==> install phase script" |
| 123 | ;; |
| 124 | deploy) |
Jack Lucas | bad7720 | 2020-02-03 18:21:29 -0500 | [diff] [blame] | 125 | build_and_push_docker |
Lusheng Ji | c8bd891 | 2017-08-29 14:11:28 +0000 | [diff] [blame] | 126 | ;; |
| 127 | *) |
| 128 | echo "==> unprocessed phase" |
| 129 | ;; |
| 130 | esac |
| 131 | |