3a236781996b70da2a5759cdfe9c08134f017060
[releng.git] / jjb / xci / xci-promote.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2018 Ericsson and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 #----------------------------------------------------------------------
12 # This script is used by CI and executed by Jenkins jobs.
13 # You are not supposed to use this script manually if you don't know
14 # what you are doing.
15 #----------------------------------------------------------------------
16
17 # ensure GERRIT_TOPIC is set
18 GERRIT_TOPIC="${GERRIT_TOPIC:-''}"
19
20 # skip the healthcheck if the patch doesn't impact the deployment
21 if [[ "$GERRIT_TOPIC" =~ skip-verify|skip-deployment ]]; then
22     echo "Skipping the healthcheck!"
23     exit 0
24 fi
25
26 # skip the deployment if the scenario is not supported on this distro
27 OPNFV_SCENARIO_REQUIREMENTS=$WORKSPACE/xci/opnfv-scenario-requirements.yml
28 if ! sed -n "/^- scenario: $DEPLOY_SCENARIO$/,/^$/p" $OPNFV_SCENARIO_REQUIREMENTS | grep -q $DISTRO; then
29     echo "# SKIPPED: Scenario $DEPLOY_SCENARIO is NOT supported on $DISTRO"
30     exit 0
31 fi
32
33 # fail if promotion metadata file doesn't exist
34 if [ ! -f $LOCAL_PROMOTION_METADATA_FILE ]; then
35     echo "Unable to find promotion metadata file $LOCAL_PROMOTION_METADATA_FILE"
36     echo "Skipping promotion!"
37     exit 1
38 fi
39
40 # upload promotion metadata file to OPNFV artifact repo
41 echo "Storing promotion metadata as $REMOTE_PROMOTION_METADATA_FILE"
42 gsutil cp $LOCAL_PROMOTION_METADATA_FILE $REMOTE_PROMOTION_METADATA_FILE
43
44 # update the file metadata on gs to prevent the use of cached version of the file
45 gsutil -m setmeta -r -h "Cache-Control:private, max-age=0, no-transform" \
46     $REMOTE_PROMOTION_METADATA_FILE > /dev/null 2>&1
47
48 # log the metadata to console
49 echo "Stored the metadata for $DEPLOY_SCENARIO"
50 echo "---------------------------------------------------------------------------------"
51 gsutil cat $REMOTE_PROMOTION_METADATA_FILE
52 echo "---------------------------------------------------------------------------------"
53 echo "Scenario $DEPLOY_SCENARIO has successfully been promoted!"