Lusheng Ji | f487f06 | 2017-08-29 14:18:43 +0000 | [diff] [blame] | 1 | #!/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 Ji | fe9c74b | 2017-09-12 02:16:34 +0000 | [diff] [blame] | 21 | set -ex |
| 22 | |
Lusheng Ji | f487f06 | 2017-08-29 14:18:43 +0000 | [diff] [blame] | 23 | echo "running script: [$0] for module [$1] at stage [$2]" |
| 24 | |
Lusheng Ji | fe9c74b | 2017-09-12 02:16:34 +0000 | [diff] [blame] | 25 | MVN_PROJECT_MODULEID="$1" |
| 26 | MVN_PHASE="$2" |
Lusheng Ji | fe9c74b | 2017-09-12 02:16:34 +0000 | [diff] [blame] | 27 | PROJECT_ROOT=$(dirname $0) |
| 28 | |
Lusheng Ji | fe9c74b | 2017-09-12 02:16:34 +0000 | [diff] [blame] | 29 | # expected environment variables |
Lusheng Ji | f487f06 | 2017-08-29 14:18:43 +0000 | [diff] [blame] | 30 | if [ -z "${MVN_NEXUSPROXY}" ]; then |
| 31 | echo "MVN_NEXUSPROXY environment variable not set. Cannot proceed" |
Lusheng Ji | 7e99e11 | 2018-02-19 23:57:20 -0500 | [diff] [blame] | 32 | exit 1 |
Lusheng Ji | f487f06 | 2017-08-29 14:18:43 +0000 | [diff] [blame] | 33 | fi |
Lusheng Ji | fe9c74b | 2017-09-12 02:16:34 +0000 | [diff] [blame] | 34 | if [ -z "$SETTINGS_FILE" ]; then |
| 35 | echo "SETTINGS_FILE environment variable not set. Cannot proceed" |
Lusheng Ji | 7e99e11 | 2018-02-19 23:57:20 -0500 | [diff] [blame] | 36 | exit 2 |
Lusheng Ji | fe9c74b | 2017-09-12 02:16:34 +0000 | [diff] [blame] | 37 | fi |
Lusheng Ji | 7e99e11 | 2018-02-19 23:57:20 -0500 | [diff] [blame] | 38 | |
| 39 | set +e |
Lusheng Ji | 30a81ab | 2018-04-02 22:57:44 -0400 | [diff] [blame^] | 40 | RELEASE_TAG=${MVN_RELEASE_TAG:-R2} |
| 41 | if [ "$RELEASE_TAG" != "R1" ]; then |
| 42 | RELEASE_TAGGED_DIR="${RELEASE_TAG}/" |
| 43 | else |
| 44 | RELEASE_TAGGED_DIR="releases" |
Lusheng Ji | 7e99e11 | 2018-02-19 23:57:20 -0500 | [diff] [blame] | 45 | fi |
Lusheng Ji | 30a81ab | 2018-04-02 22:57:44 -0400 | [diff] [blame^] | 46 | if ! 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 |
| 50 | fi |
| 51 | |
Lusheng Ji | 7e99e11 | 2018-02-19 23:57:20 -0500 | [diff] [blame] | 52 | source "${PROJECT_ROOT}"/mvn-phase-lib.sh |
Lusheng Ji | fe9c74b | 2017-09-12 02:16:34 +0000 | [diff] [blame] | 53 | |
| 54 | |
Lusheng Ji | 7e99e11 | 2018-02-19 23:57:20 -0500 | [diff] [blame] | 55 | # This is the base for where "deploy" will upload |
| 56 | # MVN_NEXUSPROXY is set in the pom.xml |
| 57 | REPO=$MVN_NEXUSPROXY/content/sites/raw/$MVN_PROJECT_GROUPID |
Lusheng Ji | f487f06 | 2017-08-29 14:18:43 +0000 | [diff] [blame] | 58 | |
Lusheng Ji | 7e99e11 | 2018-02-19 23:57:20 -0500 | [diff] [blame] | 59 | TIMESTAMP=$(date +%C%y%m%dT%H%M%S) |
| 60 | export BUILD_NUMBER="${TIMESTAMP}" |
Lusheng Ji | fe9c74b | 2017-09-12 02:16:34 +0000 | [diff] [blame] | 61 | |
Lusheng Ji | 7e99e11 | 2018-02-19 23:57:20 -0500 | [diff] [blame] | 62 | shift 2 |
Lusheng Ji | fe9c74b | 2017-09-12 02:16:34 +0000 | [diff] [blame] | 63 | |
| 64 | # Customize the section below for each project |
Lusheng Ji | f487f06 | 2017-08-29 14:18:43 +0000 | [diff] [blame] | 65 | case $MVN_PHASE in |
| 66 | clean) |
| 67 | echo "==> clean phase script" |
Lusheng Ji | fe9c74b | 2017-09-12 02:16:34 +0000 | [diff] [blame] | 68 | clean_templated_files |
| 69 | clean_tox_files |
Lusheng Ji | 7e99e11 | 2018-02-19 23:57:20 -0500 | [diff] [blame] | 70 | rm -rf ./venv-* ./*.wgn ./site logs |
Lusheng Ji | f487f06 | 2017-08-29 14:18:43 +0000 | [diff] [blame] | 71 | ;; |
| 72 | generate-sources) |
| 73 | echo "==> generate-sources phase script" |
Lusheng Ji | fe9c74b | 2017-09-12 02:16:34 +0000 | [diff] [blame] | 74 | expand_templates |
Lusheng Ji | f487f06 | 2017-08-29 14:18:43 +0000 | [diff] [blame] | 75 | ;; |
| 76 | compile) |
| 77 | echo "==> compile phase script" |
| 78 | ;; |
| 79 | test) |
| 80 | echo "==> test phase script" |
Lusheng Ji | 7e99e11 | 2018-02-19 23:57:20 -0500 | [diff] [blame] | 81 | mkdir logs |
| 82 | run_tox_test |
Lusheng Ji | f487f06 | 2017-08-29 14:18:43 +0000 | [diff] [blame] | 83 | ;; |
| 84 | package) |
| 85 | echo "==> package phase script" |
| 86 | ;; |
| 87 | install) |
| 88 | echo "==> install phase script" |
| 89 | ;; |
| 90 | deploy) |
| 91 | echo "==> deploy phase script" |
Lusheng Ji | fe9c74b | 2017-09-12 02:16:34 +0000 | [diff] [blame] | 92 | # 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 Ji | f487f06 | 2017-08-29 14:18:43 +0000 | [diff] [blame] | 97 | ;; |
| 98 | *) |
| 99 | echo "==> unprocessed phase" |
| 100 | ;; |
| 101 | esac |
| 102 | |