Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 1 | #!/bin/bash |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 2 | |
| 3 | # ================================================================================ |
Lusheng Ji | 6d381a5 | 2018-03-22 14:27:41 -0400 | [diff] [blame] | 4 | # Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved. |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 5 | # ================================================================================ |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 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 | # |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 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. |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 17 | # ============LICENSE_END========================================================= |
| 18 | # |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 19 | |
Lusheng Ji | d92d448 | 2017-09-21 05:42:28 +0000 | [diff] [blame] | 20 | |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 21 | set -ex |
| 22 | |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 23 | echo "running script: [$0] for module [$1] at stage [$2]" |
| 24 | |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 25 | MVN_PROJECT_MODULEID="$1" |
| 26 | MVN_PHASE="$2" |
Lusheng Ji | 5e11184 | 2017-09-11 23:01:37 +0000 | [diff] [blame] | 27 | PROJECT_ROOT=$(dirname $0) |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 28 | |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 29 | |
Lusheng Ji | 937f02f | 2018-03-23 13:30:20 -0400 | [diff] [blame] | 30 | echo "MVN_RELEASE_TAG is set to [$MVN_RELEASE_TAG]" |
| 31 | RELEASE_TAG=${MVN_RELEASE_TAG:-R2} |
| 32 | if [ "$RELEASE_TAG" != "R1" ]; then |
| 33 | RELEASE_TAGGED_DIR="${RELEASE_TAG}/" |
| 34 | else |
| 35 | RELEASE_TAGGED_DIR="" |
| 36 | fi |
Lusheng Ji | 6d381a5 | 2018-03-22 14:27:41 -0400 | [diff] [blame] | 37 | if ! wget -O ${PROJECT_ROOT}/mvn-phase-lib.sh \ |
Lusheng Ji | 937f02f | 2018-03-23 13:30:20 -0400 | [diff] [blame] | 38 | "$MVN_RAWREPO_BASEURL_DOWNLOAD"/org.onap.dcaegen2.utils/${RELEASE_TAGGED_DIR}scripts/mvn-phase-lib.sh; then |
| 39 | echo "Fail to download mvn-phase-lib.sh" |
| 40 | exit 1 |
Lusheng Ji | 6d381a5 | 2018-03-22 14:27:41 -0400 | [diff] [blame] | 41 | fi |
Lusheng Ji | 5e11184 | 2017-09-11 23:01:37 +0000 | [diff] [blame] | 42 | source "${PROJECT_ROOT}"/mvn-phase-lib.sh |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 43 | |
Lusheng Ji | d92d448 | 2017-09-21 05:42:28 +0000 | [diff] [blame] | 44 | |
| 45 | TIMESTAMP=$(date +%C%y%m%dT%H%M%S) |
| 46 | export BUILD_NUMBER="${TIMESTAMP}" |
Lusheng Ji | d92d448 | 2017-09-21 05:42:28 +0000 | [diff] [blame] | 47 | shift 2 |
| 48 | |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 49 | case $MVN_PHASE in |
| 50 | clean) |
| 51 | echo "==> clean phase script" |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 52 | clean_templated_files |
Lusheng Ji | 5e11184 | 2017-09-11 23:01:37 +0000 | [diff] [blame] | 53 | clean_tox_files |
Lusheng Ji | d92d448 | 2017-09-21 05:42:28 +0000 | [diff] [blame] | 54 | rm -rf ./venv-* ./*.wgn ./site ./coverage.xml ./xunit-results.xml |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 55 | ;; |
| 56 | generate-sources) |
| 57 | echo "==> generate-sources phase script" |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 58 | expand_templates |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 59 | ;; |
| 60 | compile) |
| 61 | echo "==> compile phase script" |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 62 | ;; |
| 63 | test) |
| 64 | echo "==> test phase script" |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 65 | ;; |
| 66 | package) |
| 67 | echo "==> package phase script" |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 68 | ;; |
| 69 | install) |
| 70 | echo "==> install phase script" |
Lusheng Ji | f7e6476 | 2017-10-12 05:16:59 +0000 | [diff] [blame] | 71 | case $MVN_PROJECT_MODULEID in |
| 72 | bootstrap) |
| 73 | upload_files_of_extension sh |
| 74 | ;; |
| 75 | esac |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 76 | ;; |
| 77 | deploy) |
| 78 | echo "==> deploy phase script" |
Lusheng Ji | 5e11184 | 2017-09-11 23:01:37 +0000 | [diff] [blame] | 79 | |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 80 | case $MVN_PROJECT_MODULEID in |
| 81 | bootstrap) |
Lusheng Ji | 5e11184 | 2017-09-11 23:01:37 +0000 | [diff] [blame] | 82 | # build docker image from Docker file (under module dir) and push to registry |
Lusheng Ji | f7e6476 | 2017-10-12 05:16:59 +0000 | [diff] [blame] | 83 | upload_files_of_extension sh |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 84 | build_and_push_docker |
| 85 | ;; |
Jack Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 86 | k8s-bootstrap-container|tca-cdap-container|cm-container|redis-cluster-container) |
Lusheng Ji | 6d381a5 | 2018-03-22 14:27:41 -0400 | [diff] [blame] | 87 | build_and_push_docker |
| 88 | ;; |
Lusheng Ji | c556d59 | 2017-10-17 16:50:17 -0400 | [diff] [blame] | 89 | scripts|cloud_init) |
Lusheng Ji | 5e11184 | 2017-09-11 23:01:37 +0000 | [diff] [blame] | 90 | # upload all sh file under the root of module |
Lusheng Ji | 94a4ef6 | 2017-10-16 22:14:08 -0400 | [diff] [blame] | 91 | upload_files_of_extension_recursively sh |
| 92 | upload_files_of_extension_recursively py |
Lusheng Ji | c5f346e | 2017-10-21 11:18:06 -0400 | [diff] [blame] | 93 | upload_files_of_extension_recursively yaml |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 94 | ;; |
| 95 | *) |
| 96 | echo "====> unknown mvn project module" |
| 97 | ;; |
| 98 | esac |
Andrew Gauld | b34cbd0 | 2017-08-24 16:46:17 -0400 | [diff] [blame] | 99 | ;; |
| 100 | *) |
| 101 | echo "==> unprocessed phase" |
| 102 | ;; |
| 103 | esac |
| 104 | |