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 ##############################################################################
12 GIT_URL=${GIT_URL:-https://gerrit.opnfv.org/gerrit}
13 STREAM=${STREAM:-'nostream'}
14 RELEASE_FILES=$(git diff HEAD^1 --name-only -- "releases/$STREAM")
16 # Configure the git user/email as we'll be pushing up changes
17 git config --global user.name "jenkins-ci"
18 git config --global user.email "jenkins-opnfv-ci@opnfv.org"
20 # Ensure we are able to generate Commit-IDs for new patchsets
21 curl -kLo .git/hooks/commit-msg https://gerrit.opnfv.org/gerrit/tools/hooks/commit-msg
22 chmod +x .git/hooks/commit-msg
25 echo "--> Cloning $repo"
26 if [ ! -d $repo ]; then
27 git clone $GIT_URL/$repo.git $repo
31 check_if_ref_exists(){
34 if git rev-list refs/heads/master | grep "$ref"; then
39 echo "$ref Does not exist please submit a valid ref for branching"
46 if [[ $REF_EXISTS = true && "$JOB_NAME" =~ "merge" ]]; then
47 ssh -n -f -p 29418 gerrit.opnfv.org gerrit create-branch "$repo" "$branch" "$ref"
48 python releases/scripts/create_jobs.py -f $release_file
49 NEW_FILES=$(git status --porcelain --untracked=no | cut -c4-)
51 if [ -n "$NEW_FILES" ]; then
53 git commit -sm "Create Stable Branch Jobs for $(basename $release_file .yaml)"
54 git push origin HEAD:refs/for/master
59 for release_file in $RELEASE_FILES; do
60 while read -r repo branch ref; do
61 echo "$repo" "$branch" "$ref"
62 branches="$(git ls-remote "https://gerrit.opnfv.org/gerrit/$repo.git" "refs/heads/$branch")"
63 if ! [ -z "$branches" ]; then
64 echo "refs/heads/$branch already exists at $ref ($branches)"
68 done < <(python releases/scripts/repos.py -b -f "$release_file")