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 ##############################################################################
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")
17 echo "--> Verifying $RELEASE_FILES."
18 for release_file in $RELEASE_FILES; do
20 # Verify tag for each repo exist and are attached to commits on stable-branch
21 while read -r repo tag ref
23 echo "--> Cloning $repo"
24 if [ ! -d $repo ]; then
25 git clone $GIT_URL/$repo.git $repo
27 pushd $repo &> /dev/null
29 echo "--> Checking for tag: $tag"
30 if ! (git tag -l | grep $tag &> /dev/null); then
31 echo "$tag does not exist"
34 git cat-file commit $tag
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
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"
59 # For non-merge jobs just output the ref info.
60 git show -s --format="%h %s %d" $ref
65 echo "--> Done verifing $repo"
66 done < <(python3 releases/scripts/repos.py -f $release_file)