add branch automation to the tag-releases job
Rather than creating a new job and then forcing it to run after the tag-releases job, go ahead and use the existing job and just add the new step. Change-Id: I7c481784e8c8137acbd522c654d0fa21e3fe4e0e Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
ad2f8a16b9
commit
2f1ea5cd88
|
@ -1,6 +1,6 @@
|
|||
- job:
|
||||
name: tag-releases
|
||||
description: Apply tags to repositories based on changes in deliverables files.
|
||||
description: Apply tags to repositories based on changes in deliverables files, then create requested branches.
|
||||
node: signing
|
||||
|
||||
builders:
|
||||
|
@ -18,6 +18,9 @@
|
|||
# look for modified files.
|
||||
/usr/local/jenkins/slave_scripts/release-tools/release_from_yaml.sh $(pwd)
|
||||
|
||||
# After we have tagged, create any new branches.
|
||||
/usr/local/jenkins/slave_scripts/release-tools/branch_from_yaml.sh $(pwd)
|
||||
|
||||
publishers:
|
||||
- scp:
|
||||
site: 'static.openstack.org'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Script to create stable branches based on changes to the
|
||||
# Script to create branches based on changes to the
|
||||
# deliverables files in the openstack/releases repository.
|
||||
#
|
||||
# All Rights Reserved.
|
||||
|
@ -23,15 +23,15 @@ TOOLSDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|||
source $TOOLSDIR/functions
|
||||
|
||||
function usage {
|
||||
echo "Usage: branch_from_yaml.sh releases_repository series [deliverable_files]"
|
||||
echo "Usage: branch_from_yaml.sh releases_repository [deliverable_files]"
|
||||
echo
|
||||
echo "Example: branch_from_yaml.sh ~/repos/openstack/releases mitaka"
|
||||
echo "Example: branch_from_yaml.sh ~/repos/openstack/releases mitaka"
|
||||
echo "Example: branch_from_yaml.sh ~/repos/openstack/releases mitaka deliverables/mitaka/oslo.config.yaml"
|
||||
echo "Example: branch_from_yaml.sh ~/repos/openstack/releases"
|
||||
echo "Example: branch_from_yaml.sh ~/repos/openstack/releases"
|
||||
echo "Example: branch_from_yaml.sh ~/repos/openstack/releases deliverables/mitaka/oslo.config.yaml"
|
||||
}
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "ERROR: Please specify releases_repository and series"
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "ERROR: Please specify releases_repository"
|
||||
echo
|
||||
usage
|
||||
exit 1
|
||||
|
@ -39,14 +39,12 @@ fi
|
|||
|
||||
RELEASES_REPO="$1"
|
||||
shift
|
||||
SERIES="$1"
|
||||
shift
|
||||
DELIVERABLES="$@"
|
||||
|
||||
$TOOLSDIR/list_deliverable_changes.py -r $RELEASES_REPO $DELIVERABLES \
|
||||
| while read deliverable series version diff_start repo hash pypi first_full; do
|
||||
echo "$SERIES $repo $version"
|
||||
$TOOLSDIR/make_stable_branch.sh $SERIES $repo $version
|
||||
$TOOLSDIR/list_deliverable_branches.py -r $RELEASES_REPO $DELIVERABLES \
|
||||
| while read repo branch ref; do
|
||||
echo "$repo $branch $ref"
|
||||
$TOOLSDIR/make_branch.sh $repo $branch $ref
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""Lists the branches in the modified deliverable files.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import os.path
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
PRE_RELEASE_RE = re.compile('''
|
||||
\.(\d+(?:[ab]|rc)+\d*)$
|
||||
''', flags=re.VERBOSE | re.UNICODE)
|
||||
|
||||
|
||||
def find_modified_deliverable_files(reporoot):
|
||||
"Return a list of files modified by the most recent commit."
|
||||
results = subprocess.check_output(
|
||||
['git', 'diff', '--name-only', '--pretty=format:', 'HEAD^'],
|
||||
cwd=reporoot,
|
||||
)
|
||||
filenames = [
|
||||
l.strip()
|
||||
for l in results.splitlines()
|
||||
if l.startswith('deliverables/')
|
||||
]
|
||||
return filenames
|
||||
|
||||
|
||||
def get_modified_deliverable_file_content(reporoot, filenames):
|
||||
"""Return a sequence of tuples containing the branches.
|
||||
|
||||
Return tuples containing (repository name, branch name, git
|
||||
reference)
|
||||
|
||||
"""
|
||||
# Determine which deliverable files to process by taking our
|
||||
# command line arguments or by scanning the git repository
|
||||
# for the most recent change.
|
||||
deliverable_files = filenames
|
||||
if not deliverable_files:
|
||||
deliverable_files = find_modified_deliverable_files(
|
||||
reporoot
|
||||
)
|
||||
|
||||
for basename in deliverable_files:
|
||||
filename = os.path.join(reporoot, basename)
|
||||
if not os.path.exists(filename):
|
||||
# The file must have been deleted, skip it.
|
||||
continue
|
||||
with open(filename, 'r') as f:
|
||||
deliverable_data = yaml.load(f.read())
|
||||
|
||||
# Map the release version to the release contents so we can
|
||||
# easily get a list of repositories for stable branches.
|
||||
releases_by_version = {
|
||||
r['version']: r
|
||||
for r in deliverable_data.get('releases', [])
|
||||
}
|
||||
|
||||
for branch in deliverable_data.get('branches', []):
|
||||
branch_type = branch['name'].split('/')[0]
|
||||
location = branch['location']
|
||||
|
||||
if branch_type == 'stable':
|
||||
for proj in releases_by_version[location]['projects']:
|
||||
yield (proj['repo'], branch['name'], branch['location'])
|
||||
|
||||
else:
|
||||
for repo, sha in sorted(location.items()):
|
||||
yield (repo, branch['name'], sha)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
'deliverable_file',
|
||||
nargs='*',
|
||||
help='paths to YAML files specifying releases',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--releases-repo', '-r',
|
||||
default='.',
|
||||
help='path to the releases repository for automatic scanning',
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
results = get_modified_deliverable_file_content(
|
||||
args.releases_repo,
|
||||
args.deliverable_file,
|
||||
)
|
||||
for r in results:
|
||||
print(' '.join(r))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -0,0 +1,72 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Script to create branches for a project
|
||||
#
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
if [[ $# -lt 3 ]]; then
|
||||
echo "Usage: $0 repo_name branch_name git_reference"
|
||||
echo
|
||||
echo "Example: $0 openstack/oslo.config stable/kilo 1.9.2"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
TOOLSDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $TOOLSDIR/functions
|
||||
|
||||
REPO=$1
|
||||
NEW_BRANCH=$2
|
||||
START_POINT=$3
|
||||
LPROJECT="$PROJECT"
|
||||
|
||||
PROJECT=$(basename $REPO)
|
||||
|
||||
branch_as_path_entry=$(echo $NEW_BRANCH | sed -s 's|/|-|g')
|
||||
|
||||
setup_temp_space branch-$PROJECT-$branch_as_path_entry
|
||||
clone_repo $REPO
|
||||
cd $REPO
|
||||
LANG=C git review -s
|
||||
|
||||
if $(git branch -r | grep $NEW_BRANCH > /dev/null); then
|
||||
echo "A $NEW_BRANCH branch already exists !"
|
||||
cd ../..
|
||||
rm -rf $MYTMPDIR
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Creating $NEW_BRANCH from $START_POINT"
|
||||
git branch $NEW_BRANCH $START_POINT
|
||||
REALSHA=`git show-ref -s $NEW_BRANCH`
|
||||
git push gerrit $NEW_BRANCH
|
||||
|
||||
update_gitreview "$NEW_BRANCH"
|
||||
update_upper_constraints "$NEW_BRANCH"
|
||||
|
||||
if [[ $NEW_BRANCH =~ stable/ ]]; then
|
||||
series=$(echo $NEW_BRANCH | cut -f2 -d/)
|
||||
if [[ -d releasenotes/source ]]; then
|
||||
# Also update the reno settings, in master, to add the new
|
||||
# series page.
|
||||
echo "Updating reno"
|
||||
git checkout master
|
||||
$TOOLSDIR/add_release_note_page.sh $series .
|
||||
else
|
||||
echo "$REPO does not use reno, no update needed"
|
||||
fi
|
||||
fi
|
Loading…
Reference in New Issue