X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=jjb%2Fglobal%2Freleng-macros.yml;h=d70e7e0a5ca59af26e406dc22151d86691984a0a;hb=baabd8fc2aecabcac6903f515a032054a1528bda;hp=86f4c4265e2fafea2da9a4be6e686639f54f251f;hpb=24e8cc66450544a30f031d40ed53f94154f2a349;p=releng.git diff --git a/jjb/global/releng-macros.yml b/jjb/global/releng-macros.yml index 86f4c4265..d70e7e0a5 100644 --- a/jjb/global/releng-macros.yml +++ b/jjb/global/releng-macros.yml @@ -35,6 +35,58 @@ name: GERRIT_BRANCH default: '{branch}' description: "JJB configured GERRIT_BRANCH parameter (deprecated)" + - string: + name: GERRIT_REFSPEC + default: 'refs/heads/{branch}' + description: "Default refspec needed for manually triggering." + +## +# Reporting Deployment Results +# +# To report deployment results to +# http://testresults.opnfv.org/test/#/deployresults, add the following +# parameters, builders, and publishers to a deployment job: +# +# parameters: +# - testapi-parameter +# +# builders: +# - track-begin-timestamp +# +# publishers: +# - report-provision-result +# +# Note: The following string parameter must also exist, as they are used +# when reporting the provision result: +# +# * INSTALLER +# * INSTALLER_VERSION +# * DEPLOY_SCENARIO +# +# most installers include these but you should verify first before +# adding the publisher, otherwise the deployment build may be marked +# unstable. +# +## +- parameter: + name: testapi-parameter + parameters: + - string: + name: TESTAPI_URL + default: 'http://testresults.opnfv.org/test/api/v1' + description: "Default TestAPI URL, currently using v1" + - string: + name: INSTALLER_VERSION + default: 'master' + description: "Installer release version" + - string: + name: UPSTREAM_JOB_NAME + default: '' + description: "Parent job name in Jenkins" + - string: + name: UPSTREAM_BUILD_ID + default: '' + description: "Parent job build_id in Jenkins" - property: name: logrotate-default @@ -76,6 +128,16 @@ submodule: recursive: true timeout: 20 + +- scm: + name: git-scm-openstack + scm: + - git: &git-scm-openstack-defaults + url: '$GIT_BASE' + branches: + - 'origin/$BRANCH' + timeout: 15 + - trigger: name: 'daily-trigger-disabled' triggers: @@ -141,7 +203,7 @@ - gerrit: server-name: 'gerrit.opnfv.org' trigger-on: - - ref-updated + - ref-updated-event projects: - project-compare-type: 'ANT' project-pattern: '{project}' @@ -284,127 +346,98 @@ fi - builder: - name: lint-python-code + name: upload-review-docs + builders: + - upload-under-review-docs-to-opnfv-artifacts + - report-build-result-to-gerrit + +- builder: + name: lint-init builders: - shell: | #!/bin/bash - set -o errexit - set -o pipefail - set -o xtrace - export PATH=$PATH:/usr/local/bin/ - - virtualenv -p python2.7 $WORKSPACE/releng_flake8 - source $WORKSPACE/releng_flake8/bin/activate - - # install python packages - pip install "flake8==2.6.2" - - # generate and upload lint log - echo "Running flake8 code on $PROJECT ..." - - # Get number of flake8 violations. If none, this will be an - # empty string: "" - FLAKE_COUNT="$(find . \ - -path './releng_flake8' -prune -o \ - -path './.tox' -prune -o \ - -type f -name "*.py" -print | \ - xargs flake8 --exit-zero -qq --count 2>&1)" - # Ensure we start with a clean environment - rm -f lint.log - - if [ ! -z $FLAKE_COUNT ]; then - echo "Flake8 Violations: $FLAKE_COUNT" > lint.log - find . \ - -path './releng_flake8' -prune -o \ - -path './.tox' -prune -o \ - -type f -name "*.py" -print | \ - xargs flake8 --exit-zero --first >> violation.log - SHOWN=$(wc -l violation.log | cut -d' ' -f1) - echo -e "First $SHOWN shown\n---" >> lint.log - cat violation.log >> lint.log - sed -r -i '4,$s/^/ /g' lint.log - rm violation.log - fi - - deactivate + rm -f bash-violation.log python-violation.log yaml-violation.log violation.log + git --no-pager diff --diff-filter=MCRAT --name-only HEAD^1 > modified_files - builder: - name: report-lint-result-to-gerrit + name: lint-report builders: - shell: | #!/bin/bash - set -o errexit - set -o pipefail - set -o xtrace - export PATH=$PATH:/usr/local/bin/ - - # If no violations were found, no lint log will exist. - if [[ -e lint.log ]] ; then - echo -e "\nposting linting report to gerrit...\n" - - cat lint.log - echo - - ssh -p 29418 gerrit.opnfv.org \ - "gerrit review -p $GERRIT_PROJECT \ - -m \"$(cat lint.log)\" \ - $GERRIT_PATCHSET_REVISION \ - --notify NONE" - + if [[ -s violation.log ]]; then + cat violation.log + echo "Reporting lint result...." + set -x + msg="Found syntax error and/or coding style violation(s) in the files modified by your patchset." + sed -i -e "1s#^#${msg}\n\n#" violation.log + cmd="gerrit review -p $GERRIT_PROJECT -m \"$(cat violation.log)\" $GERRIT_PATCHSET_REVISION --notify NONE" + ssh -p 29418 gerrit.opnfv.org "$cmd" + + # Make sure the caller job failed exit 1 fi - builder: - name: upload-review-docs + name: lint-bash-code builders: - - upload-under-review-docs-to-opnfv-artifacts - - report-build-result-to-gerrit + - shell: | + #!/bin/bash + echo "Checking bash code..." + for f in $(egrep '\.sh$' modified_files) + do + bash -n "$f" 2>> bash-violation.log + done + if [[ -s bash-violation.log ]]; then + echo -e "Bash syntax error(s)\n---" >> violation.log + sed -e 's/^/ /g' bash-violation.log >> violation.log + fi - builder: - name: check-bash-syntax + name: lint-python-code builders: - - shell: "find . -name '*.sh' | xargs bash -n" + - shell: | + #!/bin/bash + # Install python package + sudo pip install "flake8==2.6.2" + + echo "Checking python code..." + for f in $(egrep '\.py$' modified_files) + do + flake8 "$f" >> python-violation.log + done + if [[ -s python-violation.log ]]; then + echo -e "Python violation(s)\n---" >> violation.log + sed -e 's/^/ /g' python-violation.log >> violation.log + fi - builder: name: lint-yaml-code builders: - shell: | #!/bin/bash - set -o errexit - set -o pipefail - set -o xtrace - export PATH=$PATH:/usr/local/bin/ - - # install python packages + # sudo Install python packages sudo pip install "yamllint==1.8.2" - # generate and upload lint log - echo "Running yaml code on $PROJECT ..." - - # Get list of yaml files - YAML_FILES=$(git --no-pager diff --diff-filter=MCRAT --name-only HEAD^1 | egrep "ya?ml$") || true - - #If YAML_FILES is none exit with 0 - if [ -z "$YAML_FILES" ]; then - exit 0 - fi - - # Ensure we start with a clean environment - rm -f yaml-violation.log lint.log - - # Yamllint files only in patchset - for yamlfile in $YAML_FILES; do - yamllint $yamlfile >> yaml-violation.log || true + echo "Checking yaml file..." + for f in $(egrep '\.ya?ml$' modified_files) + do + yamllint "$f" >> yaml-violation.log done - - if [ -s "yaml-violation.log" ]; then - SHOWN=$(grep -c -v "^$" yaml-violation.log) - echo -e "First $SHOWN shown\n---" > lint.log - cat yaml-violation.log >> lint.log - sed -r -i '4,$s/^/ /g' lint.log + if [[ -s yaml-violation.log ]]; then + echo -e "YAML violation(s)\n---" >> violation.log + sed -e 's/^/ /g' yaml-violation.log >> violation.log fi +- builder: + name: lint-all-code + builders: + - lint-init + - lint-bash-code + - lint-python-code + - lint-yaml-code + - lint-report + - builder: name: clean-workspace builders: @@ -421,6 +454,12 @@ - shell: | find $WORKSPACE -type f -name '*.log' | xargs rm -f +- builder: + name: track-begin-timestamp + builders: + - shell: | + echo "export TIMESTAMP_START="\'`date '+%Y-%m-%d %H:%M:%S.%3N'`\' > $WORKSPACE/installer_track.sh + - publisher: name: archive-artifacts publishers: @@ -628,7 +667,7 @@ - email-ext: <<: *email_ptl_defaults recipients: > - hongbo.tianhongbo@huawei.com + georg.kunz@ericsson.com - publisher: name: 'email-dpacc-ptl' @@ -836,7 +875,7 @@ - email-ext: <<: *email_ptl_defaults recipients: > - jack.morgan@intel.com + zhang.jun3g@zte.com.cn - publisher: name: 'email-pharos-tools-ptl' <<: *email_pharos_ptl_defaults @@ -912,7 +951,7 @@ - email-ext: <<: *email_ptl_defaults recipients: > - ManuelBuilmbuil@suse.com + mbuil@suse.com - publisher: name: 'email-snaps-ptl' @@ -961,3 +1000,26 @@ <<: *email_ptl_defaults recipients: > ross.b.brattain@intel.com + +- publisher: + name: 'report-provision-result' + publishers: + - postbuildscript: + script-only-if-succeeded: true + builders: + - shell: | + echo "export PROVISION_RESULT=PASS" >> $WORKSPACE/installer_track.sh + echo "export INSTALLER=$INSTALLER_TYPE" >> $WORKSPACE/installer_track.sh + echo "export TIMESTAMP_END="\'`date '+%Y-%m-%d %H:%M:%S.%3N'`\' >> $WORKSPACE/installer_track.sh + - shell: + !include-raw: installer-report.sh + - postbuildscript: + script-only-if-succeeded: false + script-only-if-failed: true + builders: + - shell: | + echo "export PROVISION_RESULT=FAIL" >> $WORKSPACE/installer_track.sh + echo "export INSTALLER=$INSTALLER_TYPE" >> $WORKSPACE/installer_track.sh + echo "export TIMESTAMP_END="\'`date '+%Y-%m-%d %H:%M:%S.%3N'`\' >> $WORKSPACE/installer_track.sh + - shell: + !include-raw: installer-report.sh