Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +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 | |
| 21 | |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 22 | set -ex |
| 23 | |
| 24 | |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 25 | echo "running script: [$0] for module [$1] at stage [$2]" |
| 26 | |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 27 | MVN_PROJECT_MODULEID="$1" |
| 28 | MVN_PHASE="$2" |
| 29 | PROJECT_ROOT=$(dirname $0) |
| 30 | |
| 31 | # expected environment variables |
| 32 | if [ -z "${MVN_NEXUSPROXY}" ]; then |
| 33 | echo "MVN_NEXUSPROXY environment variable not set. Cannot proceed" |
| 34 | exit 1 |
| 35 | fi |
Andrew Gauld | 373f0f3 | 2018-02-21 11:14:46 -0500 | [diff] [blame] | 36 | export SETTINGS_FILE=${SETTINGS_FILE:-$HOME/.m2/settings.xml} |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 37 | |
Lusheng Ji | 00444ab | 2017-10-13 17:39:45 +0000 | [diff] [blame] | 38 | set +e |
Lusheng Ji | 7ed3376 | 2018-03-05 08:10:18 -0500 | [diff] [blame^] | 39 | source "${PROJECT_ROOT}"/scripts/mvn-phase-lib.sh |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 40 | |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 41 | |
Tony Hansen | 4b74774 | 2017-09-19 05:04:05 +0000 | [diff] [blame] | 42 | # This is the base for where "deploy" will upload |
| 43 | # MVN_NEXUSPROXY is set in the pom.xml |
| 44 | REPO=$MVN_NEXUSPROXY/content/sites/raw/$MVN_PROJECT_GROUPID |
| 45 | |
| 46 | TIMESTAMP=$(date +%C%y%m%dT%H%M%S) |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 47 | export BUILD_NUMBER="${TIMESTAMP}" |
| 48 | |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 49 | |
Tony Hansen | 4b74774 | 2017-09-19 05:04:05 +0000 | [diff] [blame] | 50 | shift 2 |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 51 | |
| 52 | case $MVN_PHASE in |
| 53 | clean) |
| 54 | echo "==> clean phase script" |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 55 | case $MVN_PROJECT_MODULEID in |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 56 | *) |
| 57 | clean_templated_files |
| 58 | clean_tox_files |
| 59 | rm -rf ./venv-* ./*.wgn ./site ./coverage.xml ./xunit-results.xml |
| 60 | ;; |
| 61 | esac |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 62 | ;; |
| 63 | generate-sources) |
| 64 | echo "==> generate-sources phase script" |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 65 | case $MVN_PROJECT_MODULEID in |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 66 | *) |
| 67 | expand_templates |
| 68 | ;; |
| 69 | esac |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 70 | ;; |
| 71 | compile) |
| 72 | echo "==> compile phase script" |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 73 | case $MVN_PROJECT_MODULEID in |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 74 | *) |
| 75 | ;; |
| 76 | esac |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 77 | ;; |
| 78 | test) |
| 79 | echo "==> test phase script" |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 80 | case $MVN_PROJECT_MODULEID in |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 81 | *) |
Andrew Gauld | 373f0f3 | 2018-02-21 11:14:46 -0500 | [diff] [blame] | 82 | if [ -f tox.ini ] |
| 83 | then |
| 84 | set -e |
| 85 | run_tox_test |
| 86 | set +e |
| 87 | fi |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 88 | ;; |
| 89 | esac |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 90 | ;; |
| 91 | package) |
| 92 | echo "==> package phase script" |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 93 | case $MVN_PROJECT_MODULEID in |
Lusheng Ji | 310c9c1 | 2017-10-13 21:45:18 +0000 | [diff] [blame] | 94 | scripts) |
| 95 | upload_files_of_extension "sh" "$MVN_PROJECT_MODULEID" |
| 96 | ;; |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 97 | *) |
| 98 | ;; |
| 99 | esac |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 100 | ;; |
| 101 | install) |
| 102 | echo "==> install phase script" |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 103 | case $MVN_PROJECT_MODULEID in |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 104 | *) |
| 105 | ;; |
| 106 | esac |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 107 | ;; |
| 108 | deploy) |
| 109 | echo "==> deploy phase script" |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 110 | case $MVN_PROJECT_MODULEID in |
Lusheng Ji | 00444ab | 2017-10-13 17:39:45 +0000 | [diff] [blame] | 111 | scripts) |
| 112 | upload_files_of_extension "sh" "$MVN_PROJECT_MODULEID" |
| 113 | ;; |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 114 | *) |
Lusheng Ji | a7a5837 | 2017-09-20 03:57:14 +0000 | [diff] [blame] | 115 | # uncomment after we figure out how to use pypi. this command expects that the credentials are passed in |
| 116 | # settings.xml, and the URL and serverid are passed in from either oparent or dcaegen2's root pom |
| 117 | # before this is ready comment below out |
| 118 | #generate_pypirc_then_publish |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 119 | ;; |
| 120 | esac |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 121 | ;; |
| 122 | *) |
| 123 | echo "==> unprocessed phase" |
| 124 | ;; |
| 125 | esac |
| 126 | |