Upgrade k8s-plugin to 3.6.0
[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   case $MVN_PROJECT_MODULEID in
66   dcae-services-policy-sync)
67     set -e -x
68     CURDIR=$(pwd)
69     TOXINIS=$(find . -name "tox.ini")
70     for TOXINI in "${TOXINIS[@]}"; do
71       DIR=$(echo "$TOXINI" | rev | cut -f2- -d'/' | rev)
72       cd "${CURDIR}/${DIR}"
73       rm -rf ./venv-tox ./.tox
74       virtualenv ./venv-tox
75       source ./venv-tox/bin/activate
76       pip install pip==20.3.4
77       pip install --upgrade argparse
78       pip install tox
79       pip freeze
80       tox
81       deactivate
82       rm -rf ./venv-tox ./.tox
83     done 
84     ;;
85   esac
86   ;;
87 package)
88   echo "==> package phase script"
89   ;;
90 install)
91   echo "==> install phase script"
92   case $MVN_PROJECT_MODULEID in
93   bootstrap)
94     upload_files_of_extension sh
95     ;;
96   esac
97   ;;
98 deploy)
99   echo "==> deploy phase script"
100
101   case $MVN_PROJECT_MODULEID in
102   cm-container|healthcheck-container|tls-init-container|consul-loader-container|multisite-init-container|dcae-k8s-cleanup-container|dcae-services-policy-sync)
103     build_and_push_docker
104     ;;
105   *)
106     echo "====> unknown mvn project module"
107     ;;
108   esac
109   ;;
110 *)
111   echo "==> unprocessed phase"
112   ;;
113 esac
114