From 3c55ae20558dcc48a4ee2801d23b9d2566f286c8 Mon Sep 17 00:00:00 2001 From: Graeme A Stewart <graeme.andrew.stewart@cern.ch> Date: Sun, 26 Feb 2017 15:28:10 +0100 Subject: [PATCH] Add helper script for tagging a nightly build This script will tag a Jenkins nightly build, using the name of the current branch and the timestamp defined in the $datestamp variable or given on the command line. It should be used as a generic part of any production nightly Jenkins build of athena. --- Build/AtlasBuildScripts/tag_build.sh | 68 ++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 Build/AtlasBuildScripts/tag_build.sh diff --git a/Build/AtlasBuildScripts/tag_build.sh b/Build/AtlasBuildScripts/tag_build.sh new file mode 100755 index 00000000000..bf55462ad69 --- /dev/null +++ b/Build/AtlasBuildScripts/tag_build.sh @@ -0,0 +1,68 @@ +#! /bin/bash +# +# Copyright (C) 2017 CERN for the benefit of the ATLAS collaboration +# + +# Function printing the usage information for the script +usage() { + echo "Usage: tag_build.sh [-d date_stamp] [-u repository_url]" \ + " Tag a 'nightly' build based on the current branch and timestamp."\ + " This script should really only be used by NICOS to tag nightly builds."\ + " Private builds should not do this."\ + " 'date_stamp' defaults to $datestamp, repository_url to the ATLAS athena"\ + " repository in CERN GitLab (krb5 authenticated)" +} + +# Parse the command line arguments: +DATESTAMP="$datestamp" +REPOURL="https://:@gitlab.cern.ch:8443/atlas/athena.git" +while getopts ":d:u:h" opt; do + case $opt in + d) + DATESTAMP=$OPTARG + ;; + u) + REPOURL=$OPTARG + ;; + h) + usage + exit 0 + ;; + :) + echo "Argument -$OPTARG requires a parameter!" + usage + exit 1 + ;; + ?) + echo "Unknown argument: -$OPTARG" + usage + exit 1 + ;; + esac +done + +# Check we got a datestamp and that it's a valid format +if [ "$DATESTAMP" = "" ]; then + echo "No date_stamp defined from NICOS or given as a parameter" + exit 1 +fi +echo $DATESTAMP | egrep "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{4}$" >& /dev/null +if [ $? != "0" ]; then + echo "Datestamp '$DATESTAMP' does not correspond to the ATLAS format YYYY-MM-DDTHHMM" + exit 1 +fi + +# Abort if any of the next commands fail +set -e + +# Use the source of this script to ensure that we cd to within the root of the +# local repository +ScriptSrcDir=$(dirname ${BASH_SOURCE[0]}) +cd $ScriptSrcDir/../.. + +# Get branch name, then tag and push +BRANCH=$(git symbolic-ref --short HEAD) +TAG="nightly/$BRANCH/$DATESTAMP" +echo "Creating tag $TAG" +git tag $TAG +git push $REPOURL $TAG -- GitLab