Remove former docker build jobs
[releng.git] / jjb / releng / releng-release-tagging.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2018 The Linux Foundation 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 set -e -o pipefail
11 set -x
12
13 GIT_URL=${GIT_URL:-https://gerrit.opnfv.org/gerrit}
14 STREAM=${STREAM:-'nostream'}
15 RELEASE_FILES=$(git diff HEAD^1 --name-only -- "releases/$STREAM")
16
17 echo "--> Verifying $RELEASE_FILES."
18 for release_file in $RELEASE_FILES; do
19
20     # Verify tag for each repo exist and are attached to commits on stable-branch
21     while read -r repo tag ref
22     do
23       echo "--> Cloning $repo"
24       if [ ! -d $repo ]; then
25           git clone $GIT_URL/$repo.git $repo
26       fi
27       pushd $repo &> /dev/null
28
29       echo "--> Checking for tag: $tag"
30       if ! (git tag -l | grep $tag &> /dev/null); then
31           echo "$tag does not exist"
32           TAG_EXISTS=false
33       else
34           git cat-file commit $tag
35           TAG_EXISTS=true
36       fi
37
38       echo "--> Checking if $ref is on stable/$STREAM"
39       if ! (git branch -a --contains $ref | grep "stable/$STREAM"); then
40           echo "--> ERROR: $ref for $repo is not on stable/$STREAM!"
41           # If the tag exists but is on the wrong ref, there's nothing
42           # we can do. But if the tag neither exists nor is on the
43           # correct branch we need to fail the verification.
44           if [ $TAG_EXISTS = false ]; then
45               exit 1
46           fi
47       else
48           if [[ $TAG_EXISTS = false && "$JOB_NAME" =~ "merge" ]]; then
49               # If the tag doesn't exist and we're in a merge job,
50               # everything has been verified up to this point and we
51               # are ready to create the tag.
52               git config --global user.name "fbot"
53               git config --global user.email "jenkins-opnfv-ci@opnfv.org"
54               echo "--> Creating $tag tag for $repo at $ref"
55               git tag -am "$tag" $tag $ref
56               echo "--> Pushing tag"
57               git push origin $tag
58           else
59               # For non-merge jobs just output the ref info.
60               git show -s --format="%h %s %d" $ref
61           fi
62       fi
63
64       popd &> /dev/null
65       echo "--> Done verifing $repo"
66     done < <(python3 releases/scripts/repos.py -f $release_file)
67 done