From bb0c0d708a9f6175e0f97f4db0a24922b8e66fe6 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Fri, 21 Apr 2017 19:41:51 -0400 Subject: [PATCH] Add job to perform branch cutting Provide a Jenkins job which: 1) Creates stable/RELEASE branches 2) Updates .gitreview on stable/RELEASE branches This job also archives relevant log information and creates reproducible patches in case manual intervention is necessary. Change-Id: Iebca81965ed59f82533cf0419425be0540bd14b8 Signed-off-by: Thanh Ha --- jjb/autorelease/autorelease-projects.yaml | 1 + jjb/autorelease/autorelease-templates.yaml | 51 ++++++++++ jjb/autorelease/branch-cut.sh | 108 +++++++++++++++++++++ 3 files changed, 160 insertions(+) create mode 100644 jjb/autorelease/branch-cut.sh diff --git a/jjb/autorelease/autorelease-projects.yaml b/jjb/autorelease/autorelease-projects.yaml index 12f6f6004..9cc046516 100644 --- a/jjb/autorelease/autorelease-projects.yaml +++ b/jjb/autorelease/autorelease-projects.yaml @@ -2,6 +2,7 @@ - project: name: autorelease-projects jobs: + - autorelease-branch-cut - 'autorelease-generate-release-notes-{stream}' - 'autorelease-release-{stream}': build-node: centos7-autorelease-4c-16g diff --git a/jjb/autorelease/autorelease-templates.yaml b/jjb/autorelease/autorelease-templates.yaml index 94141d552..495787e1f 100644 --- a/jjb/autorelease/autorelease-templates.yaml +++ b/jjb/autorelease/autorelease-templates.yaml @@ -1,5 +1,56 @@ --- # Autorelease build jobs +- job-template: + name: autorelease-branch-cut + + ##################### + # Job Configuration # + ##################### + + project-type: freestyle + node: centos7-builder-2c-2g + + properties: + - opendaylight-infra-properties: + build-days-to-keep: 7 + + parameters: + - lf-infra-parameters: + project: releng/autorelease + branch: master + stream: master + lftools-version: '{lftools-version}' + - string: + name: RELEASE + description: | + Release name to branch cut. + Eg. Lithium, Beryllium, Boron, Carbon... + - bool: + name: DRY_RUN + default: true + description: | + If DRY_RUN is enabled modifications are not published to Gerrit. + + scm: + - lf-infra-gerrit-scm: + git-url: '$GIT_URL/$GERRIT_PROJECT' + branch: master + refspec: 'refs/heads/master' + jenkins-ssh-credential: opendaylight-jenkins-ssh + submodule-recursive: true + choosing-strategy: default + + wrappers: + - lf-infra-wrappers: + build-timeout: 10 + jenkins-ssh-credential: opendaylight-jenkins-ssh + + builders: + - shell: !include-raw-escape: branch-cut.sh + + publishers: + - lf-infra-publish + - job-template: name: 'autorelease-release-{stream}' diff --git a/jjb/autorelease/branch-cut.sh b/jjb/autorelease/branch-cut.sh new file mode 100644 index 000000000..02df34e22 --- /dev/null +++ b/jjb/autorelease/branch-cut.sh @@ -0,0 +1,108 @@ +#!/bin/bash +# @License EPL-1.0 +############################################################################## +# Copyright (c) 2017 The Linux Foundation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +############################################################################## + +# This script requires the user running the script to have "Create References" +# permission in Gerrit for the "stable/RELEASE" branch. Where RELEASE is an +# official OpenDaylight release. Eg. Oxygen, Nitrogen, Carbon, etc... +# +# Performs 2 actions: +# +# 1) Creates a new branch stable/RELEASE (where release is a ODL release, +# eg Oxygen, Nitrogen, Carbon, etc...) +# 2) Updates .gitreview in the new stable/RELEASE branch to set the +# defaultbranch to the new branch. +# +# Required Parameters: +# RELEASE: The name of the release to create a branch for. + +mkdir -p "$WORKSPACE/archives" +LOG_FILE="$WORKSPACE/archives/branch-cut.log" + +set -eu -o pipefail + +# Validate inputs +if [ -z "$RELEASE" ]; then + echo "ERROR: RELEASE variable most be set to a release name. Eg Carbon" + exit 1 +fi + +# --- Start create new maintenance branch +echo "---> Creating new mainenance branch" +git submodule foreach git fetch origin +git fetch origin +git submodule foreach git checkout -b "stable/${RELEASE,,}" origin/master +git checkout -b "stable/${RELEASE,,}" origin/master + +########## +# Verify # +########## + +{ + echo "---> Verify maintenance branch" + git submodule foreach git branch + git branch +} | tee -a "$LOG_FILE" + +######## +# Push # +######## + +if [ "$DRY_RUN" = false ] +then + echo "Pushing stable/${RELEASE,,} branches to Gerrit" + git submodule foreach git push gerrit "stable/${RELEASE,,}" + git push gerrit "stable/$RELEASE" +fi +# --- End create new maintenance branch + +# --- Start update .gitreview +echo "---> Update .gitreview" +git submodule foreach sed -i -e "s#defaultbranch=master#defaultbranch=stable/${RELEASE,,}#" .gitreview +git submodule foreach git add .gitreview +git submodule foreach "git commit -sm 'Update .gitreview to stable/${RELEASE,,}'" +sed -i -e "s#defaultbranch=master#defaultbranch=stable/${RELEASE,,}#" .gitreview +git add .gitreview +git commit -sm "Update .gitreview to stable/${RELEASE,,}" + +# Generate git patches +patch_dir="$WORKSPACE/archives/patches/git-review" +mkdir -p "$patch_dir" +for module in $(git submodule | awk '{ print $2 }') +do + pushd "$module" + git format-patch --stdout "origin/master" > "$patch_dir/${module//\//-}.patch" + git bundle create "$patch_dir/${module//\//-}.bundle" "origin/master..HEAD" + popd +done + +########## +# Verify # +########## + +{ + echo "---> Verify .gitreview" + git submodule foreach git show HEAD + git show HEAD + git submodule foreach git log --oneline -2 --graph --decorate + git log --oneline -2 --graph --decorate +} | tee -a "$LOG_FILE" + +######## +# Push # +######## + +if [ "$DRY_RUN" = false ] +then + echo "Pushing .gitreview patches to Gerrit" + git submodule foreach git review -t "branch-cut-${RELEASE,,}" + git review -t "branch-cut-${RELEASE,,}" +fi +# --- Stop update .gitreview -- 2.36.6