[cm-container] Fix CM restart issue
[dcaegen2/deployments.git] / mvn-phase-script.sh
1 #!/bin/bash
2
3 # ================================================================================
4 # Copyright (c) 2017-2018 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
20
21 set -ex
22
23 echo "running script: [$0] for module [$1] at stage [$2]"
24
25 MVN_PROJECT_MODULEID="$1"
26 MVN_PHASE="$2"
27 PROJECT_ROOT=$(dirname $0)
28
29
30 echo "MVN_RELEASE_TAG is set to [$MVN_RELEASE_TAG]"
31 RELEASE_TAG=${MVN_RELEASE_TAG:-R8}
32 if [ "$RELEASE_TAG" != "R1" ]; then
33   RELEASE_TAGGED_DIR="${RELEASE_TAG}/"
34 else
35   RELEASE_TAGGED_DIR=""
36 fi
37 if ! wget -O ${PROJECT_ROOT}/mvn-phase-lib.sh \
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
41 fi
42 source "${PROJECT_ROOT}"/mvn-phase-lib.sh
43
44
45 TIMESTAMP=$(date +%C%y%m%dT%H%M%S)
46 export BUILD_NUMBER="${TIMESTAMP}"
47 shift 2
48
49 case $MVN_PHASE in
50 clean)
51   echo "==> clean phase script"
52   clean_templated_files
53   clean_tox_files
54   rm -rf ./venv-* ./*.wgn ./site ./coverage.xml ./xunit-results.xml
55   ;;
56 generate-sources)
57   echo "==> generate-sources phase script"
58   expand_templates
59   ;;
60 compile)
61   echo "==> compile phase script"
62   ;;
63 test)
64   echo "==> test phase script"
65   ;;
66 package)
67   echo "==> package phase script"
68   ;;
69 install)
70   echo "==> install phase script"
71   case $MVN_PROJECT_MODULEID in
72   bootstrap)
73     upload_files_of_extension sh
74     ;;
75   esac
76   ;;
77 deploy)
78   echo "==> deploy phase script"
79
80   case $MVN_PROJECT_MODULEID in
81   bootstrap)
82     # build docker image from Docker file (under module dir) and push to registry
83     upload_files_of_extension sh
84     build_and_push_docker
85     ;;
86   tca-cdap-container|cm-container|redis-cluster-container|healthcheck-container|pnda-mirror-container|pnda-bootstrap-container|tls-init-container|consul-loader-container|multisite-init-container|dcae-k8s-cleanup-container)
87     build_and_push_docker
88     ;;
89   scripts|cloud_init|heat)
90     # upload all sh file under the root of module
91     upload_files_of_extension_recursively sh $MVN_PROJECT_MODULEID
92     upload_files_of_extension_recursively py $MVN_PROJECT_MODULEID
93     upload_files_of_extension_recursively yaml $MVN_PROJECT_MODULEID
94     ;;
95   *)
96     echo "====> unknown mvn project module"
97     ;;
98   esac
99   ;;
100 *)
101   echo "==> unprocessed phase"
102   ;;
103 esac
104