Make translation pushes to gerrit branch aware

To support multiple translation versions in Zanata we need to make the
reverse push into Gerrit branch aware as well. Do this by setting up the
existing propose translation jobs to accept a branch parameter which
tells them which version to pull from Zanata and where to push into
Gerrit.

This will add a new periodic jenkins job for each release/branch.

Change-Id: Ia206bfaa7dd6eaad6aa1f6e5ddbbbf9cdadf8db0
This commit is contained in:
Clark Boylan 2015-09-21 10:16:58 -07:00
parent 1a06e58eae
commit 624832c5fa
3 changed files with 27 additions and 13 deletions

View File

@ -15,15 +15,15 @@
node: 'proposal' node: 'proposal'
- job-template: - job-template:
name: '{name}-propose-translation-update' name: '{name}-propose-translation-update{suffix}'
builders: builders:
- revoke-sudo - revoke-sudo
- branch-git-prep: - branch-git-prep:
branch: master branch: '{branch}'
- shell: | - shell: |
#!/bin/bash -xe #!/bin/bash -xe
/usr/local/jenkins/slave_scripts/propose_translation_update.sh {name} /usr/local/jenkins/slave_scripts/propose_translation_update.sh {name} {branch}
publishers: publishers:
- console-log - console-log
@ -33,15 +33,19 @@
- job-group: - job-group:
name: translation-jobs name: translation-jobs
suffix: ''
branch: master
jobs: jobs:
- '{name}-upstream-translation-update' - '{name}-upstream-translation-update'
- '{name}-propose-translation-update' - '{name}-propose-translation-update{suffix}'
- job-group: - job-group:
name: manual-translation-jobs name: manual-translation-jobs
suffix: ''
branch: master
jobs: jobs:
- '{name}-upstream-translation-update' - '{name}-upstream-translation-update'
- '{name}-propose-translation-update' - '{name}-propose-translation-update{suffix}'
- 'gate-{name}-tox-{envlist}': - 'gate-{name}-tox-{envlist}':
envlist: checklang envlist: checklang
- '{name}-tox-doc-{envlist}': - '{name}-tox-doc-{envlist}':

View File

@ -132,6 +132,9 @@ function setup_manuals {
# Setup project so that git review works, sets global variable # Setup project so that git review works, sets global variable
# COMMIT_MSG. # COMMIT_MSG.
function setup_review { function setup_review {
# Note we cannot rely on the default branch in .gitreview being
# correct so we are very explicit here.
local branch=${1:-master}
FULL_PROJECT=$(grep project .gitreview | cut -f2 -d= |sed -e 's/\.git$//') FULL_PROJECT=$(grep project .gitreview | cut -f2 -d= |sed -e 's/\.git$//')
set +e set +e
read -d '' COMMIT_MSG <<EOF read -d '' COMMIT_MSG <<EOF
@ -146,7 +149,7 @@ EOF
# See if there is an open change in the zanata/translations # See if there is an open change in the zanata/translations
# topic. If so, get the change id for the existing change for use # topic. If so, get the change id for the existing change for use
# in the commit msg. # in the commit msg.
change_info=$(ssh -p 29418 proposal-bot@review.openstack.org gerrit query --current-patch-set status:open project:$FULL_PROJECT topic:zanata/translations owner:proposal-bot) change_info=$(ssh -p 29418 proposal-bot@review.openstack.org gerrit query --current-patch-set status:open project:$FULL_PROJECT branch:$branch topic:zanata/translations owner:proposal-bot)
previous=$(echo "$change_info" | grep "^ number:" | awk '{print $2}') previous=$(echo "$change_info" | grep "^ number:" | awk '{print $2}')
if [ -n "$previous" ]; then if [ -n "$previous" ]; then
change_id=$(echo "$change_info" | grep "^change" | awk '{print $2}') change_id=$(echo "$change_info" | grep "^change" | awk '{print $2}')
@ -189,6 +192,7 @@ EOF
# Propose patch using COMMIT_MSG # Propose patch using COMMIT_MSG
function send_patch { function send_patch {
local branch=${1:-master}
# We don't have any repos storing zanata.xml, so just remove it. # We don't have any repos storing zanata.xml, so just remove it.
rm -f zanata.xml rm -f zanata.xml
@ -199,7 +203,9 @@ function send_patch {
git commit -F- <<EOF git commit -F- <<EOF
$COMMIT_MSG $COMMIT_MSG
EOF EOF
git review -t zanata/translations # We cannot rely on the default branch in .gitreview being
# correct so we are very explicit here.
git review -t zanata/translations $branch
fi fi
} }

View File

@ -13,6 +13,10 @@
# under the License. # under the License.
PROJECT=$1 PROJECT=$1
BRANCH=$2
# Replace /'s in the branch name with -'s because Zanata does not
# allow /'s in version names.
ZANATA_VERSION=${BRANCH//\//-}
source /usr/local/jenkins/slave_scripts/common_translation_update.sh source /usr/local/jenkins/slave_scripts/common_translation_update.sh
@ -155,25 +159,25 @@ function propose_django_openstack_auth {
setup_git setup_git
# Check whether a review already exists, setup review commit message. # Check whether a review already exists, setup review commit message.
setup_review setup_review "$BRANCH"
case "$PROJECT" in case "$PROJECT" in
api-site|ha-guide|openstack-manuals|operations-guide|security-doc) api-site|ha-guide|openstack-manuals|operations-guide|security-doc)
init_manuals "$PROJECT" init_manuals "$PROJECT"
setup_manuals "$PROJECT" setup_manuals "$PROJECT" "$ZANATA_VERSION"
propose_manuals propose_manuals
;; ;;
django_openstack_auth) django_openstack_auth)
setup_django_openstack_auth setup_django_openstack_auth "$ZANATA_VERSION"
propose_django_openstack_auth propose_django_openstack_auth
;; ;;
horizon) horizon)
setup_horizon setup_horizon "$ZANATA_VERSION"
propose_horizon propose_horizon
;; ;;
*) *)
# Project specific setup. # Project specific setup.
setup_project "$PROJECT" setup_project "$PROJECT" "$ZANATA_VERSION"
# Setup some global vars which will be used in the rest of the # Setup some global vars which will be used in the rest of the
# script. # script.
setup_loglevel_vars setup_loglevel_vars
@ -185,4 +189,4 @@ esac
filter_commits filter_commits
# Propose patch to gerrit if there are changes. # Propose patch to gerrit if there are changes.
send_patch send_patch "$BRANCH"