Lusheng Ji | 1694802 | 2017-09-11 23:38:09 +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 | eab1675 | 2017-09-19 18:39:04 +0000 | [diff] [blame^] | 22 | FQDN="${MVN_PROJECT_GROUPID}.${MVN_PROJECT_ARTIFACTID}" |
| 23 | if [ "$MVN_PROJECT_MODULEID" == "__" ]; then |
| 24 | MVN_PROJECT_MODULEID="" |
| 25 | fi |
| 26 | |
| 27 | if [[ "$MVN_PROJECT_VERSION" == *SNAPSHOT ]]; then |
| 28 | echo "=> for SNAPSHOT artifact build" |
| 29 | MVN_DEPLOYMENT_TYPE='SNAPSHOT' |
| 30 | MVN_DOCKERREGISTRY="$MVN_DOCKERREGISTRY_SNAPSHOT" |
| 31 | MVN_DOCKERREGISTRY_SERVERID="$MVN_DOCKERREGISTRY_SNAPSHOT_SERVERID" |
| 32 | else |
| 33 | echo "=> for STAGING/RELEASE artifact build" |
| 34 | MVN_DEPLOYMENT_TYPE='STAGING' |
| 35 | # below is not mistake. we only use the snapshot registry |
| 36 | MVN_DOCKERREGISTRY="$MVN_DOCKERREGISTRY_SNAPSHOT" |
| 37 | MVN_DOCKERREGISTRY_SERVERID="$MVN_DOCKERREGISTRY_SNAPSHOT_SERVERID" |
| 38 | fi |
| 39 | echo "MVN_DEPLOYMENT_TYPE is [$MVN_DEPLOYMENT_TYPE]" |
| 40 | |
| 41 | |
| 42 | TIMESTAMP=$(date +%C%y%m%dT%H%M%S) |
| 43 | |
| 44 | # WROKSPACE points to the current dir when the script is called, may be the root or module |
| 45 | if [ -z "$WORKSPACE" ]; then |
| 46 | WORKSPACE=$(pwd) |
| 47 | fi |
| 48 | |
| 49 | |
| 50 | TIMESTAMP=$(date +%C%y%m%dT%H%M%S) |
| 51 | |
| 52 | |
| 53 | |
| 54 | echo "MVN_PROJECT_MODULEID is [$MVN_PROJECT_MODULEID]" |
| 55 | echo "MVN_PHASE is [$MVN_PHASE]" |
| 56 | echo "MVN_PROJECT_GROUPID is [$MVN_PROJECT_GROUPID]" |
| 57 | echo "MVN_PROJECT_ARTIFACTID is [$MVN_PROJECT_ARTIFACTID]" |
| 58 | echo "MVN_PROJECT_VERSION is [$MVN_PROJECT_VERSION]" |
| 59 | echo "MVN_NEXUSPROXY is [$MVN_NEXUSPROXY]" |
| 60 | echo "MVN_RAWREPO_BASEURL_UPLOAD is [$MVN_RAWREPO_BASEURL_UPLOAD]" |
| 61 | echo "MVN_RAWREPO_BASEURL_DOWNLOAD is [$MVN_RAWREPO_BASEURL_DOWNLOAD]" |
| 62 | MVN_RAWREPO_HOST=$(echo "$MVN_RAWREPO_BASEURL_UPLOAD" | cut -f3 -d'/' |cut -f1 -d':') |
| 63 | echo "MVN_RAWREPO_HOST is [$MVN_RAWREPO_HOST]" |
| 64 | echo "MVN_RAWREPO_SERVERID is [$MVN_RAWREPO_SERVERID]" |
| 65 | echo "MVN_DOCKERREGISTRY is [$MVN_DOCKERREGISTRY]" |
| 66 | echo "MVN_DOCKERREGISTRY_SERVERID is [$MVN_DOCKERREGISTRY_SERVERID]" |
| 67 | echo "MVN_PYPISERVER_BASEURL is [$MVN_PYPISERVER_BASEURL]" |
| 68 | echo "MVN_PYPISERVER_SERVERID is [$MVN_PYPISERVER_SERVERID]" |
| 69 | echo "FQDN is [$FQDN]" |
| 70 | echo "MVN_PROJECT_MODULEID is [$MVN_PROJECT_MODULEID]" |
| 71 | echo "MVN_DEPLOYMENT_TYPE is [$MVN_DEPLOYMENT_TYPE]" |
| 72 | |
| 73 | |
Lusheng Ji | 1694802 | 2017-09-11 23:38:09 +0000 | [diff] [blame] | 74 | clean_templated_files() |
| 75 | { |
| 76 | TEMPLATE_FILES=$(find . -name "*-template") |
| 77 | for F in $TEMPLATE_FILES; do |
| 78 | F2=$(echo "$F" | sed 's/-template$//') |
| 79 | rm -f "$F2" |
| 80 | done |
| 81 | } |
| 82 | clean_tox_files() |
| 83 | { |
| 84 | TOX_FILES=$(find . -name ".tox") |
| 85 | TOX_FILES="$TOX_FILES $(find . -name 'venv-tox')" |
| 86 | for F in $TOX_FILES; do |
| 87 | rm -rf "$F" |
| 88 | done |
| 89 | } |
| 90 | |
| 91 | expand_templates() |
| 92 | { |
| 93 | # set up env variables, get ready for template resolution |
| 94 | # NOTE: CCSDK artifacts do not distinguish REALESE vs SNAPSHOTs |
| 95 | export ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.ccsdk.platform.plugins" |
| 96 | export ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_snapshots="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.ccsdk.platform.plugins" |
| 97 | export ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_blueprints_releases="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.ccsdk.platform.blueprints" |
| 98 | export ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_blueprints_snapshots="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.ccsdk.platform.blueprints" |
| 99 | |
| 100 | export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_releases="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2/releases" |
| 101 | export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_snapshots="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2/snapshots" |
| 102 | export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_releases="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2.platform.plugins/releases" |
| 103 | export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_snapshots="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2.platform.plugins/snapshots" |
| 104 | export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_blueprints_releases="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2.platform.blueprints/releases" |
| 105 | export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_blueprints_snapshots="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2.platform.blueprints/snapshots" |
| 106 | |
| 107 | export ONAPTEMPLATE_PYPIURL_org_onap_dcaegen2="${MVN_NEXUSPROXY}/content/sites/pypi" |
| 108 | |
| 109 | export ONAPTEMPLATE_DOCKERREGURL_org_onap_dcaegen2_releases="$MVN_DOCKERREGISTRY_DAILY" |
| 110 | export ONAPTEMPLATE_DOCKERREGURL_org_onap_dcaegen2_snapshots="$MVN_DOCKERREGISTRY_DAILY/snapshots" |
| 111 | |
| 112 | |
| 113 | TEMPLATE_FILES=$(find . -name "*-template") |
| 114 | for F in $TEMPLATE_FILES; do |
| 115 | F2=$(echo "$F" | sed 's/-template$//') |
| 116 | cp "$F" "$F2" |
| 117 | MOD=$(stat --format '%a' "$F") |
| 118 | chmod "$MOD" "$F2" |
| 119 | done |
| 120 | |
| 121 | |
| 122 | TEMPLATES=$(env |grep ONAPTEMPLATE) |
| 123 | if [ -z "$TEMPLATES" ]; then |
| 124 | return 0 |
| 125 | fi |
| 126 | |
| 127 | echo "====> Resolving the following temaplate from environment variables " |
| 128 | echo "[$TEMPLATES]" |
| 129 | SELFFILE=$(echo "$0" | rev | cut -f1 -d '/' | rev) |
| 130 | for TEMPLATE in $TEMPLATES; do |
| 131 | KEY=$(echo "$TEMPLATE" | cut -f1 -d'=') |
| 132 | VALUE=$(echo "$TEMPLATE" | cut -f2 -d'=') |
| 133 | VALUE2=$(echo "$TEMPLATE" | cut -f2 -d'=' |sed 's/\//\\\//g') |
| 134 | set +e |
| 135 | FILES=$(grep -rl "$KEY") |
| 136 | set -e |
| 137 | |
| 138 | if [ -z "$FILES" ]; then |
| 139 | continue |
| 140 | fi |
| 141 | |
| 142 | # assuming FILES is not longer than 2M bytes, the limit for variable value max size on this VM |
| 143 | for F in $FILES; do |
| 144 | if [[ $F == *"$SELFFILE" ]]; then |
| 145 | continue |
| 146 | fi |
| 147 | if [[ "$F" == *-template ]]; then |
| 148 | continue |
| 149 | fi |
| 150 | |
| 151 | echo "======> Resolving template $KEY to value $VALUE for file $F" |
| 152 | sed -i "s/{{[[:space:]]*$KEY[[:space:]]*}}/$VALUE2/g" "$F" |
| 153 | #cat "$F" |
| 154 | done |
| 155 | |
| 156 | #if [ ! -z "$FILES" ]; then |
| 157 | # echo "====> Resolving template $VALUE to value $VALUE" |
| 158 | # #CMD="grep -rl \"$VALUE\" | tr '\n' '\0' | xargs -0 sed -i \"s/{{[[:space:]]*$VALUE[[:space:]]*}}/$VALUE/g\"" |
| 159 | # grep -rl "$KEY" | tr '\n' '\0' | xargs -0 sed -i 's/$KEY/$VALUE2/g' |
| 160 | # #echo $CMD |
| 161 | # #eval $CMD |
| 162 | #fi |
| 163 | done |
| 164 | echo "====> Done template reolving" |
| 165 | } |
| 166 | |
| 167 | |
| 168 | run_tox_test() |
| 169 | { |
| 170 | set -x |
| 171 | CURDIR=$(pwd) |
| 172 | TOXINIS=$(find . -name "tox.ini") |
| 173 | for TOXINI in "${TOXINIS[@]}"; do |
| 174 | DIR=$(echo "$TOXINI" | rev | cut -f2- -d'/' | rev) |
| 175 | cd "${CURDIR}/${DIR}" |
| 176 | rm -rf ./venv-tox ./.tox |
| 177 | virtualenv ./venv-tox |
| 178 | source ./venv-tox/bin/activate |
| 179 | pip install --upgrade pip |
| 180 | pip install --upgrade tox argparse |
| 181 | pip freeze |
| 182 | tox |
| 183 | deactivate |
| 184 | rm -rf ./venv-tox ./.tox |
| 185 | done |
| 186 | } |
| 187 | |
| 188 | build_wagons() |
| 189 | { |
| 190 | rm -rf ./*.wgn venv-pkg |
| 191 | |
| 192 | SETUPFILES=$(find . -name "setup.py") |
| 193 | for SETUPFILE in $SETUPFILES; do |
| 194 | PLUGIN_DIR=$(echo "$SETUPFILE" |rev | cut -f 2- -d '/' |rev) |
| 195 | PLUGIN_NAME=$(grep 'name' "$SETUPFILE" | cut -f2 -d'=' | sed 's/[^0-9a-zA-Z\.]*//g') |
| 196 | PLUGIN_VERSION=$(grep 'version' "$SETUPFILE" | cut -f2 -d'=' | sed 's/[^0-9\.]*//g') |
| 197 | |
| 198 | echo "In $PLUGIN_DIR, $PLUGIN_NAME, $PLUGIN_VERSION" |
| 199 | |
| 200 | virtualenv ./venv-pkg |
| 201 | source ./venv-pkg/bin/activate |
| 202 | pip install --upgrade pip |
| 203 | pip install wagon |
| 204 | wagon create --format tar.gz "$PLUGIN_DIR" |
| 205 | deactivate |
| 206 | rm -rf venv-pkg |
| 207 | |
| 208 | PKG_FILE_NAMES=( "${PLUGIN_NAME}-${PLUGIN_VERSION}"*.wgn ) |
| 209 | echo Built package: "${PKG_FILE_NAMES[@]}" |
| 210 | done |
| 211 | } |
| 212 | |
| 213 | |
| 214 | upload_raw_file() |
| 215 | { |
| 216 | # Extract the username and password to the nexus repo from the settings file |
| 217 | USER=$(xpath -q -e "//servers/server[id='$MVN_RAWREPO_SERVERID']/username/text()" "$SETTINGS_FILE") |
| 218 | PASS=$(xpath -q -e "//servers/server[id='$MVN_RAWREPO_SERVERID']/password/text()" "$SETTINGS_FILE") |
| 219 | NETRC=$(mktemp) |
| 220 | echo "machine $MVN_RAWREPO_HOST login $USER password $PASS" > "$NETRC" |
| 221 | |
| 222 | REPO="$MVN_RAWREPO_BASEURL_UPLOAD" |
| 223 | |
| 224 | OUTPUT_FILE=$1 |
| 225 | EXT=$(echo "$OUTPUT_FILE" | rev |cut -f1 -d '.' |rev) |
| 226 | if [ "$EXT" == 'yaml' ]; then |
| 227 | OUTPUT_FILE_TYPE='text/x-yaml' |
| 228 | elif [ "$EXT" == 'sh' ]; then |
| 229 | OUTPUT_FILE_TYPE='text/x-shellscript' |
| 230 | elif [ "$EXT" == 'gz' ]; then |
| 231 | OUTPUT_FILE_TYPE='application/gzip' |
| 232 | elif [ "$EXT" == 'wgn' ]; then |
| 233 | OUTPUT_FILE_TYPE='application/gzip' |
| 234 | else |
| 235 | OUTPUT_FILE_TYPE='application/octet-stream' |
| 236 | fi |
| 237 | |
| 238 | |
| 239 | if [ "$MVN_DEPLOYMENT_TYPE" == 'SNAPSHOT' ]; then |
| 240 | SEND_TO="${REPO}/${FQDN}/snapshots" |
| 241 | elif [ "$MVN_DEPLOYMENT_TYPE" == 'STAGING' ]; then |
| 242 | SEND_TO="${REPO}/${FQDN}/releases" |
| 243 | else |
| 244 | echo "Unreconfnized deployment type, quit" |
| 245 | exit |
| 246 | fi |
| 247 | if [ ! -z "$MVN_PROJECT_MODULEID" ]; then |
| 248 | SEND_TO="$SEND_TO/$MVN_PROJECT_MODULEID" |
| 249 | fi |
| 250 | |
| 251 | echo "Sending ${OUTPUT_FILE} to Nexus: ${SEND_TO}" |
| 252 | curl -vkn --netrc-file "${NETRC}" --upload-file "${OUTPUT_FILE}" -X PUT -H "Content-Type: $OUTPUT_FILE_TYPE" "${SEND_TO}/${OUTPUT_FILE}-${MVN_PROJECT_VERSION}-${TIMESTAMP}" |
| 253 | curl -vkn --netrc-file "${NETRC}" --upload-file "${OUTPUT_FILE}" -X PUT -H "Content-Type: $OUTPUT_FILE_TYPE" "${SEND_TO}/${OUTPUT_FILE}-${MVN_PROJECT_VERSION}" |
| 254 | curl -vkn --netrc-file "${NETRC}" --upload-file "${OUTPUT_FILE}" -X PUT -H "Content-Type: $OUTPUT_FILE_TYPE" "${SEND_TO}/${OUTPUT_FILE}" |
| 255 | } |
| 256 | |
| 257 | |
| 258 | |
| 259 | upload_wagons_and_type_yamls() |
| 260 | { |
| 261 | WAGONS=$(ls -1 ./*.wgn) |
| 262 | for WAGON in $WAGONS ; do |
| 263 | WAGON_NAME=$(echo "$WAGON" | cut -f1 -d '-') |
| 264 | WAGON_VERSION=$(echo "$WAGON" | cut -f2 -d '-') |
| 265 | WAGON_TYPEFILE=$(grep -rl "$WAGON_NAME" | grep yaml | head -1) |
| 266 | |
| 267 | upload_raw_file "$WAGON" |
| 268 | upload_raw_file "$WAGON_TYPEFILE" |
| 269 | done |
| 270 | } |
| 271 | |
| 272 | upload_files_of_extension() |
| 273 | { |
| 274 | FILES=$(ls -1 ./*."$1") |
| 275 | for F in $FILES ; do |
| 276 | upload_raw_file "$F" |
| 277 | done |
| 278 | } |
| 279 | |
| 280 | |
Lusheng Ji | eab1675 | 2017-09-19 18:39:04 +0000 | [diff] [blame^] | 281 | upload_files_of_extension_rec() |
| 282 | { |
| 283 | FILES=$(find . -name "*.${1}") |
| 284 | for F in $FILES ; do |
| 285 | upload_raw_file "$F" |
| 286 | done |
| 287 | } |
| 288 | |
| 289 | |
Lusheng Ji | 1694802 | 2017-09-11 23:38:09 +0000 | [diff] [blame] | 290 | |
| 291 | build_and_push_docker() |
| 292 | { |
| 293 | IMAGENAME="onap/${FQDN}.${MVN_PROJECT_MODULEID}" |
| 294 | IMAGENAME=$(echo "$IMAGENAME" | sed -e 's/_*$//g' -e 's/\.*$//g') |
Lusheng Ji | eab1675 | 2017-09-19 18:39:04 +0000 | [diff] [blame^] | 295 | IMAGENAME=$(echo "$IMAGENAME" | tr '[:upper:]' '[:lower:]') |
Lusheng Ji | 1694802 | 2017-09-11 23:38:09 +0000 | [diff] [blame] | 296 | |
| 297 | # use the major and minor version of the MVN artifact version as docker image version |
| 298 | VERSION="${MVN_PROJECT_VERSION//[^0-9.]/}" |
| 299 | VERSION2=$(echo "$VERSION" | cut -f1-2 -d'.') |
| 300 | |
| 301 | LFQI="${IMAGENAME}:${VERSION}-${TIMESTAMP}" |
Lusheng Ji | 869ede1 | 2017-09-12 03:24:27 +0000 | [diff] [blame] | 302 | # build a docker image |
| 303 | docker build --rm -f ./Dockerfile -t "${LFQI}" ./ |
Lusheng Ji | 1694802 | 2017-09-11 23:38:09 +0000 | [diff] [blame] | 304 | |
Lusheng Ji | eab1675 | 2017-09-19 18:39:04 +0000 | [diff] [blame^] | 305 | REPO="$MVN_DOCKERREGISTRY" |
| 306 | SERVERID="$MVN_DOCKERREGISTRY_SERVERID" |
Lusheng Ji | 1694802 | 2017-09-11 23:38:09 +0000 | [diff] [blame] | 307 | |
| 308 | if [ ! -z "$REPO" ]; then |
Lusheng Ji | eab1675 | 2017-09-19 18:39:04 +0000 | [diff] [blame^] | 309 | USER=$(xpath -e "//servers/server[id='$SERVERID']/username/text()" "$SETTINGS_FILE") |
| 310 | PASS=$(xpath -e "//servers/server[id='$SERVERID']/password/text()" "$SETTINGS_FILE") |
Lusheng Ji | 1694802 | 2017-09-11 23:38:09 +0000 | [diff] [blame] | 311 | if [ -z "$USER" ]; then |
| 312 | echo "Error: no user provided" |
| 313 | fi |
| 314 | if [ -z "$PASS" ]; then |
| 315 | echo "Error: no password provided" |
| 316 | fi |
| 317 | [ -z "$PASS" ] && PASS_PROVIDED="<empty>" || PASS_PROVIDED="<password>" |
| 318 | echo docker login "$REPO" -u "$USER" -p "$PASS_PROVIDED" |
| 319 | docker login "$REPO" -u "$USER" -p "$PASS" |
| 320 | |
| 321 | if [ $MVN_DEPLOYMENT_TYPE == "SNAPSHOT" ]; then |
| 322 | REPO="$REPO/snapshots" |
| 323 | elif [ $MVN_DEPLOYMENT_TYPE == "STAGING" ]; then |
| 324 | # there seems to be no staging docker registry? set to use SNAPSHOT also |
| 325 | #REPO=$MVN_DOCKERREGISTRY_RELEASE |
| 326 | REPO="$REPO" |
| 327 | else |
| 328 | echo "Fail to determine DEPLOYMENT_TYPE" |
| 329 | REPO="$REPO/unknown" |
| 330 | fi |
| 331 | |
| 332 | OLDTAG="${LFQI}" |
| 333 | PUSHTAGS="${REPO}/${IMAGENAME}:${VERSION2}-${TIMESTAMP} ${REPO}/${IMAGENAME}:${VERSION2} ${REPO}/${IMAGENAME}:${VERSION2}-latest" |
| 334 | for NEWTAG in ${PUSHTAGS} |
| 335 | do |
| 336 | echo "tagging ${OLDTAG} to ${NEWTAG}" |
| 337 | docker tag "${OLDTAG}" "${NEWTAG}" |
| 338 | echo "pushing ${NEWTAG}" |
| 339 | docker push "${NEWTAG}" |
| 340 | OLDTAG="${NEWTAG}" |
| 341 | done |
| 342 | fi |
| 343 | |
| 344 | } |
| 345 | |
| 346 | |
| 347 | |
Lusheng Ji | eab1675 | 2017-09-19 18:39:04 +0000 | [diff] [blame^] | 348 | push_docker_image() |
| 349 | { |
| 350 | if [ -z "$1" ]; then |
| 351 | return |
| 352 | fi |
| 353 | OLDTAGNAME="$1" |
| 354 | OLDREPO=$(echo $TAGNAME | cut -f1 -d '/') |
| 355 | IMAGENAME_W_VERSION=$(echo $TAGNAME | cut -f2- -d '/') |
| 356 | |
| 357 | # build a docker image |
| 358 | docker pull "$OLDTAGNAME" |
| 359 | |
| 360 | REPO="$MVN_DOCKERREGISTRY" |
| 361 | SERVERID="$MVN_DOCKERREGISTRY_SERVERID" |
| 362 | |
| 363 | if [ ! -z "$REPO" ]; then |
| 364 | USER=$(xpath -e "//servers/server[id='$SERVERID']/username/text()" "$SETTINGS_FILE") |
| 365 | PASS=$(xpath -e "//servers/server[id='$SERVERID']/password/text()" "$SETTINGS_FILE") |
| 366 | if [ -z "$USER" ]; then |
| 367 | echo "Error: no user provided" |
| 368 | fi |
| 369 | if [ -z "$PASS" ]; then |
| 370 | echo "Error: no password provided" |
| 371 | fi |
| 372 | [ -z "$PASS" ] && PASS_PROVIDED="<empty>" || PASS_PROVIDED="<password>" |
| 373 | echo docker login "$REPO" -u "$USER" -p "$PASS_PROVIDED" |
| 374 | docker login "$REPO" -u "$USER" -p "$PASS" |
| 375 | |
| 376 | if [ $MVN_DEPLOYMENT_TYPE == "SNAPSHOT" ]; then |
| 377 | REPO="$REPO/snapshots" |
| 378 | elif [ $MVN_DEPLOYMENT_TYPE == "STAGING" ]; then |
| 379 | # there seems to be no staging docker registry? set to use SNAPSHOT also |
| 380 | #REPO=$MVN_DOCKERREGISTRY_RELEASE |
| 381 | REPO="$REPO" |
| 382 | else |
| 383 | echo "Fail to determine DEPLOYMENT_TYPE" |
| 384 | REPO="$REPO/unknown" |
| 385 | fi |
| 386 | |
| 387 | OLDTAG="${OLDTAGNAME}" |
| 388 | PUSHTAGS="${REPO}/${IMAGENAME_W_VERSION}-${TIMESTAMP} ${REPO}/${IMAGENAME_W_VERSION} ${REPO}/${IMAGENAME_W_VERSION}-latest" |
| 389 | for NEWTAG in ${PUSHTAGS} |
| 390 | do |
| 391 | echo "tagging ${OLDTAG} to ${NEWTAG}" |
| 392 | docker tag "${OLDTAG}" "${NEWTAG}" |
| 393 | echo "pushing ${NEWTAG}" |
| 394 | docker push "${NEWTAG}" |
| 395 | OLDTAG="${NEWTAG}" |
| 396 | done |
| 397 | fi |
| 398 | |
| 399 | } |
| 400 | |
| 401 | |
| 402 | |