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 |
| 36 | if [ -z "$SETTINGS_FILE" ]; then |
| 37 | echo "SETTINGS_FILE environment variable not set. Cannot proceed" |
| 38 | exit 2 |
| 39 | fi |
| 40 | |
| 41 | |
| 42 | source "${PROJECT_ROOT}"/mvn-phase-lib.sh |
| 43 | |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 44 | |
Tony Hansen | 4b74774 | 2017-09-19 05:04:05 +0000 | [diff] [blame] | 45 | # This is the base for where "deploy" will upload |
| 46 | # MVN_NEXUSPROXY is set in the pom.xml |
| 47 | REPO=$MVN_NEXUSPROXY/content/sites/raw/$MVN_PROJECT_GROUPID |
| 48 | |
| 49 | TIMESTAMP=$(date +%C%y%m%dT%H%M%S) |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 50 | export BUILD_NUMBER="${TIMESTAMP}" |
| 51 | |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 52 | |
Tony Hansen | 4b74774 | 2017-09-19 05:04:05 +0000 | [diff] [blame] | 53 | shift 2 |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 54 | |
| 55 | case $MVN_PHASE in |
| 56 | clean) |
| 57 | echo "==> clean phase script" |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 58 | case $MVN_PROJECT_MODULEID in |
Lusheng Ji | a7a5837 | 2017-09-20 03:57:14 +0000 | [diff] [blame^] | 59 | check-blueprint-vs-input | repackage) |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 60 | if [ -f makefile -o -f Makefile ];then make clean; else :; fi |
| 61 | ;; |
| 62 | *) |
| 63 | clean_templated_files |
| 64 | clean_tox_files |
| 65 | rm -rf ./venv-* ./*.wgn ./site ./coverage.xml ./xunit-results.xml |
| 66 | ;; |
| 67 | esac |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 68 | ;; |
| 69 | generate-sources) |
| 70 | echo "==> generate-sources phase script" |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 71 | case $MVN_PROJECT_MODULEID in |
Lusheng Ji | a7a5837 | 2017-09-20 03:57:14 +0000 | [diff] [blame^] | 72 | check-blueprint-vs-input | repackage) |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 73 | if [ -f makefile -o -f Makefile ];then make generate-sources; else :; fi |
| 74 | ;; |
| 75 | *) |
| 76 | expand_templates |
| 77 | ;; |
| 78 | esac |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 79 | ;; |
| 80 | compile) |
| 81 | echo "==> compile phase script" |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 82 | case $MVN_PROJECT_MODULEID in |
Lusheng Ji | a7a5837 | 2017-09-20 03:57:14 +0000 | [diff] [blame^] | 83 | check-blueprint-vs-input | repackage) |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 84 | if [ -f makefile -o -f Makefile ];then make compile; else :; fi |
| 85 | ;; |
| 86 | *) |
| 87 | ;; |
| 88 | esac |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 89 | ;; |
| 90 | test) |
| 91 | echo "==> test phase script" |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 92 | case $MVN_PROJECT_MODULEID in |
Lusheng Ji | a7a5837 | 2017-09-20 03:57:14 +0000 | [diff] [blame^] | 93 | check-blueprint-vs-input | repackage) |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 94 | if [ -f makefile -o -f Makefile ];then make test; else :; fi |
| 95 | ;; |
| 96 | *) |
| 97 | set +e |
| 98 | run_tox_test |
| 99 | set -e |
| 100 | ;; |
| 101 | esac |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 102 | ;; |
| 103 | package) |
| 104 | echo "==> package phase script" |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 105 | case $MVN_PROJECT_MODULEID in |
Lusheng Ji | a7a5837 | 2017-09-20 03:57:14 +0000 | [diff] [blame^] | 106 | check-blueprint-vs-input | repackage) |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 107 | if [ -f makefile -o -f Makefile ];then make package; else :; fi |
| 108 | ;; |
| 109 | *) |
| 110 | ;; |
| 111 | esac |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 112 | ;; |
| 113 | install) |
| 114 | echo "==> install phase script" |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 115 | case $MVN_PROJECT_MODULEID in |
Lusheng Ji | a7a5837 | 2017-09-20 03:57:14 +0000 | [diff] [blame^] | 116 | check-blueprint-vs-input | repackage) |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 117 | if [ -f makefile -o -f Makefile ];then make install; else :; fi |
| 118 | ;; |
| 119 | *) |
| 120 | ;; |
| 121 | esac |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 122 | ;; |
| 123 | deploy) |
| 124 | echo "==> deploy phase script" |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 125 | case $MVN_PROJECT_MODULEID in |
Lusheng Ji | a7a5837 | 2017-09-20 03:57:14 +0000 | [diff] [blame^] | 126 | check-blueprint-vs-input | repackage) |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 127 | if [ -f makefile -o -f Makefile ];then make deploy |
| 128 | else |
| 129 | # Upload all files (listed as additional deployment arguments) to Nexus |
| 130 | # additional |
| 131 | for artifact |
| 132 | do |
| 133 | upload_raw_file $artifact |
| 134 | done |
| 135 | set +e +x |
| 136 | fi |
| 137 | ;; |
| 138 | *) |
Lusheng Ji | a7a5837 | 2017-09-20 03:57:14 +0000 | [diff] [blame^] | 139 | # uncomment after we figure out how to use pypi. this command expects that the credentials are passed in |
| 140 | # settings.xml, and the URL and serverid are passed in from either oparent or dcaegen2's root pom |
| 141 | # before this is ready comment below out |
| 142 | #generate_pypirc_then_publish |
Lusheng Ji | 88648fc | 2017-09-20 02:18:20 +0000 | [diff] [blame] | 143 | ;; |
| 144 | esac |
Lusheng Ji | 5bc79f4 | 2017-08-29 14:20:46 +0000 | [diff] [blame] | 145 | ;; |
| 146 | *) |
| 147 | echo "==> unprocessed phase" |
| 148 | ;; |
| 149 | esac |
| 150 | |