diff --git a/jenkins/jobs/translation-jobs.yaml b/jenkins/jobs/translation-jobs.yaml index c65a1aaf6d..9a50147581 100644 --- a/jenkins/jobs/translation-jobs.yaml +++ b/jenkins/jobs/translation-jobs.yaml @@ -8,7 +8,7 @@ - gerrit-git-prep - shell: | #!/bin/bash -xe - /usr/local/jenkins/slave_scripts/upstream_translation_update.sh {name} + /usr/local/jenkins/slave_scripts/upstream_translation_update.sh {name} {template-name} publishers: - console-log @@ -18,6 +18,13 @@ - source: 'translation-source/**/*.pot' target: 'tarballs/' keep-hierarchy: true + - scp: + site: 'static.openstack.org' + files: + - target: 'logs/$LOG_PATH' + source: 'testrepository.subunit.gz' + keep-hierarchy: false + copy-after-failure: true - proposal-slave-cleanup node: 'proposal' @@ -33,10 +40,17 @@ branch: '{branch}' - shell: | #!/bin/bash -xe - /usr/local/jenkins/slave_scripts/propose_translation_update.sh {name} {branch} + /usr/local/jenkins/slave_scripts/propose_translation_update.sh {name} {branch} {template-name} publishers: - console-log + - scp: + site: 'static.openstack.org' + files: + - target: 'logs/$LOG_PATH' + source: 'testrepository.subunit.gz' + keep-hierarchy: false + copy-after-failure: true - proposal-slave-cleanup node: 'proposal' diff --git a/jenkins/scripts/common_translation_update.sh b/jenkins/scripts/common_translation_update.sh index 6e903144cb..8c1dac319c 100644 --- a/jenkins/scripts/common_translation_update.sh +++ b/jenkins/scripts/common_translation_update.sh @@ -16,6 +16,10 @@ source /usr/local/jenkins/slave_scripts/common.sh +# Set start of timestamp for subunit +TRANS_START_TIME=$(date +%s) +SUBUNIT_OUTPUT=testrepository.subunit + # Topic to use for our changes TOPIC=zanata/translations @@ -25,6 +29,12 @@ QUIET="--quiet" # Have invalid files been found? INVALID_PO_FILE=0 +# ERROR_ABORT signals whether the script aborts with failure, will be +# set to 0 on successfull run. +ERROR_ABORT=1 + +trap "finish" EXIT + # Set up some branch dependent variables function init_branch { local branch=$1 @@ -46,6 +56,27 @@ function get_modulename { -p $project -t $target } +function finish { + + if [[ "$ERRORS" -eq 1 ]] ; then + $VENV/bin/generate-subunit $TRANS_START_TIME $SECONDS 'fail' $JOBNAME >> $SUBUNIT_OUTPUT + + else + $VENV/bin/generate-subunit $TRANS_START_TIME $SECONDS 'success' $JOBNAME >> $SUBUNIT_OUTPUT + fi + + gzip -9 $SUBUNIT_OUTPUT + + # Delete temporary directories + if [ "$VENV" != "" ] ; then + rm -rf $VENV + VENV="" + fi + if [ "$HORIZON_ROOT" != "" ] ; then + rm -rf $HORIZON_ROOT + HORIZON_ROOT="" + fi +} # Setup venv with Babel in it. # Also extract version of project. @@ -54,7 +85,6 @@ function setup_venv { # Note that this directory needs to be outside of the source tree, # some other functions will fail if it's inside. VENV=$(mktemp -d) - trap "rm -rf $VENV" EXIT virtualenv $VENV # Install babel using global upper constraints. @@ -69,6 +99,10 @@ function setup_venv { VERSION=$($VENV/bin/python setup.py --version) set -e VERSION=${VERSION:-unknown} + + # Install subunit for the subunit output stream for + # healthcheck.openstack.org. + $VENV/bin/pip install -U os-testr } # Setup a project for Zanata. This is used by both Python and Django projects. @@ -327,16 +361,15 @@ function install_horizon { # TODO(jaegerandi): Switch to zuul-cloner once it's safe to use # zuul-cloner in post jobs and we have a persistent cache on # proposal node. - root=$(mktemp -d) - # Note this trap handler overrides the trap handler from - # setup_venv for $VENV. - trap "rm -rf $VENV $root" EXIT + HORIZON_ROOT=$(mktemp -d) # Checkout same branch of horizon as the project - including # same constraints. git clone --depth=1 --branch $GIT_BRANCH \ - git://git.openstack.org/openstack/horizon.git $root/horizon - (cd ${root}/horizon && $VENV/bin/pip install -c $UPPER_CONSTRAINTS .) + git://git.openstack.org/openstack/horizon.git $HORIZON_ROOT/horizon + (cd ${HORIZON_ROOT}/horizon && $VENV/bin/pip install -c $UPPER_CONSTRAINTS .) + rm -rf HORIZON_ROOT + HORIZON_ROOT="" } diff --git a/jenkins/scripts/propose_translation_update.sh b/jenkins/scripts/propose_translation_update.sh index 7c00447dbc..bc1ab7dfa6 100755 --- a/jenkins/scripts/propose_translation_update.sh +++ b/jenkins/scripts/propose_translation_update.sh @@ -14,6 +14,8 @@ PROJECT=$1 BRANCH=$2 +JOBNAME=$3 + # Replace /'s in the branch name with -'s because Zanata does not # allow /'s in version names. ZANATA_VERSION=${BRANCH//\//-} @@ -221,3 +223,5 @@ if [ $INVALID_PO_FILE -eq 1 ] ; then echo "translation server." exit 1 fi +# Tell finish function that everything is fine. +ERROR_ABORT=0 diff --git a/jenkins/scripts/upstream_translation_update.sh b/jenkins/scripts/upstream_translation_update.sh index 3f2c303499..1032f940c3 100755 --- a/jenkins/scripts/upstream_translation_update.sh +++ b/jenkins/scripts/upstream_translation_update.sh @@ -13,6 +13,7 @@ # under the License. PROJECT=$1 +JOBNAME=$2 # Replace /'s in branch names with -'s because Zanata doesn't # allow /'s in version names. @@ -30,6 +31,9 @@ if ! /usr/local/jenkins/slave_scripts/query-zanata-project-version.py \ # Exit successfully so that lack of a version doesn't cause the jenkins # jobs to fail. This is necessary because not all branches of a project # will be translated. + + # Tell finish function that everything is fine. + ERROR_ABORT=0 exit 0 fi @@ -115,3 +119,6 @@ if [ $(git diff --cached | egrep -v "(POT-Creation-Date|^[\+\-]#|^\+{3}|^\-{3})" mv .translation-source translation-source fi + +# Tell finish function that everything is fine. +ERROR_ABORT=0