summaryrefslogtreecommitdiffstats
path: root/jjb/xci/xci-promote.sh
blob: d8d61bee2153358a66e39a2f79ae19c0700f3d3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2018 Ericsson and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

#----------------------------------------------------------------------
# This script is used by CI and executed by Jenkins jobs.
# You are not supposed to use this script manually if you don't know
# what you are doing.
#----------------------------------------------------------------------

# ensure GERRIT_TOPIC is set
GERRIT_TOPIC="${GERRIT_TOPIC:-''}"

# skip the healthcheck if the patch doesn't impact the deployment
if [[ "$GERRIT_TOPIC" =~ skip-verify|skip-deployment ]]; then
    echo "Skipping the healthcheck!"
    exit 0
fi

# fail if promotion metadata file doesn't exist
if [ ! -f $LOCAL_PROMOTION_METADATA_FILE ]; then
    echo "Unable to find promotion metadata file $LOCAL_PROMOTION_METADATA_FILE"
    echo "Skipping promotion!"
    exit 1
fi

# put additional info into the metadata file so we can use that for displaying the information
echo "PROMOTED_BY=$BUILD_URL" >> $LOCAL_PROMOTION_METADATA_FILE
echo "PROMOTED_ON=$(date -u '+%F_%H:%M'UTC)" >> $LOCAL_PROMOTION_METADATA_FILE

# upload promotion metadata file to OPNFV artifact repo
echo "Storing promotion metadata as $REMOTE_PROMOTION_METADATA_FILE"
gsutil cp $LOCAL_PROMOTION_METADATA_FILE $REMOTE_PROMOTION_METADATA_FILE > /dev/null 2>&1

# update the file metadata on gs to prevent the use of cached version of the file
gsutil -m setmeta -r -h "Content-Type:text/html" \
    -h "Cache-Control:private, max-age=0, no-transform" \
    $REMOTE_PROMOTION_METADATA_FILE > /dev/null 2>&1

# log the metadata to console
echo "Stored the metadata for $DEPLOY_SCENARIO"
echo "---------------------------------------------------------------------------------"
gsutil cat $REMOTE_PROMOTION_METADATA_FILE
echo "---------------------------------------------------------------------------------"
echo "Scenario $DEPLOY_SCENARIO has successfully been promoted!"