blob: 854b87679d8abebed57edad471dd79c4f2135040 [file] [log] [blame]
- builder:
name: merge-target-branch
builders:
- shell: |
#!/bin/bash -e
cd gerrit
git fetch origin $TARGET_BRANCH
git config user.name "Jenkins Build"
git config user.email "jenkins@gerritforge.com"
git merge --no-commit --no-edit --no-ff FETCH_HEAD
- builder:
name: fetch-all-submodules
builders:
- shell: |
#!/bin/bash -e
set +x
cd gerrit
function fetch_submodules {
# We do need to call update even if we know it will fail: the submodules git needs
# to be initialised and made it pointing to the correct remote submodule URL
git submodule update > /dev/null 2> /dev/null || true
export SUBMODULES=$(git submodule status | awk '{print $2}')
for module in $SUBMODULES
do
echo "Fetching all changes refs for $module ..."
pushd $module > /dev/null
git fetch -q origin +refs/changes/*:refs/changes/*
popd > /dev/null
done
}
git submodule init
# Fetch submodules refs/changes as fallback action of a submodule update failure
echo "Updating all submodules ..."
git submodule update || ( fetch_submodules && git submodule update )
- defaults:
name: verifier-defaults
concurrent: true
parameters:
- string:
name: CHANGE_URL
description: "Gerrit Change URL to build"
- string:
name: REFSPEC
description: "Git refspec to use for fetching changes"
- string:
name: BRANCH
description: "Git SHA1 of the path-set to verify"
- string:
name: TARGET_BRANCH
description: "Git target branch of the change"
- choice:
name: MODE
choices:
- reviewdb
- notedb
- polygerrit
description: "Type of verification to execute"
properties:
- authorization:
anonymous:
- job-discover
- job-read
- job-extended-read
- build-discarder:
days-to-keep: 7
scm:
- git:
url: https://gerrit.googlesource.com/gerrit
refspec: $REFSPEC
branches:
- $BRANCH
submodule:
disable: true
skip-tag: true
basedir: gerrit
wrappers:
- xvfb:
installation-name: Xvfb
display-name: 1
parallel-build: false
timeout: 60
screen: 1024x768x16
additional-options: -fbdir /tmp
debug: true
shutdown-with-build: false
- raw:
xml: |
<hudson.plugins.build__timeout.BuildTimeoutWrapper plugin="build-timeout@1.16">
<strategy class="hudson.plugins.build_timeout.impl.NoActivityTimeOutStrategy">
<timeoutSecondsString>750</timeoutSecondsString>
</strategy>
<operationList>
<hudson.plugins.build__timeout.operations.AbortOperation/>
</operationList>
</hudson.plugins.build__timeout.BuildTimeoutWrapper>
- raw:
xml: <jenkins.plugins.logstash.LogstashBuildWrapper plugin="logstash@1.2.0"/>
publishers:
- groovy-postbuild:
script: "(manager.logContains('timed out') || manager.logContains('TIMEOUT in ')) ? manager.buildAborted() : false"
- job:
name: Gerrit-verifier-buck
description: "Gerrit build of open change with BUCK\n"
defaults: verifier-defaults
builders:
- merge-target-branch
- fetch-all-submodules
- shell:
!include-raw-escape: gerrit-buck-build.sh
- shell:
!include-raw-escape: gerrit-buck-verifier-test.sh
publishers:
- archive:
artifacts: >
gerrit/buck-out/gen/*.war,gerrit/buck-out/gen/plugins/*/*.jar,gerrit/buck-out/gen/*api/*api.jar,
gerrit/buck-out/gen/gerrit-acceptance-framework/*.jar
excludes: 'gerrit/buck-out/gen/plugins/core*/**/*.jar'
- job:
name: Gerrit-verifier-bazel
description: "Gerrit build of open change with Bazel\n"
defaults: verifier-defaults
node: bazel-debian
builders:
- merge-target-branch
- fetch-all-submodules
- shell:
!include-raw-escape: gerrit-bazel-build.sh
- shell:
!include-raw-escape: gerrit-bazel-verifier-test.sh
- shell:
!include-raw-escape: gerrit-bazel-cat-test-log.sh
publishers:
- archive:
artifacts: >
gerrit/bazel-bin/*.war,gerrit/bazel-genfiles/plugins/*/*.jar,
gerrit/bazel-genfiles/*api/*api.jar,
gerrit/bazel-genfiles/gerrit-acceptance-framework/*.jar
excludes: 'gerrit/bazel-genfiles/plugins/core*/**/*.jar'
- job:
name: Gerrit-codestyle
description: "Gerrit code-style checker for an open change\n"
defaults: verifier-defaults
node: bazel-debian
builders:
- merge-target-branch
- fetch-all-submodules
- shell: |
#!/bin/bash -xe
cd gerrit
GJF_VERSION=$(grep -o "^VERSION=.*$" tools/setup_gjf.sh | grep -o "[0-9][0-9]*\.[0-9][0-9]*")
GJF="/home/jenkins/format/google-java-format-$GJF_VERSION"
if [ ! -f "$GJF" ]; then
./tools/setup_gjf.sh
GJF=$(find 'tools/format' -regex '.*/google-java-format-[0-9][0-9]*\.[0-9][0-9]*')
fi
echo 'Running google-java-format check...'
git show --diff-filter=AM --name-only --pretty="" HEAD | grep java$ | xargs -r $GJF -n --set-exit-if-changed
- shell: |
#!/bin/bash -xe
cd gerrit
if ([ "$TARGET_BRANCH" == "master" ] || [ "$TARGET_BRANCH" == "stable-3.0" ] || [ "$TARGET_BRANCH" == "stable-2.16" ] || [ "$TARGET_BRANCH" == "stable-2.15" ]) && git show --diff-filter=AM --name-only --pretty="" HEAD | grep polygerrit-ui
then
echo 'Running PolyGerrit lint check...'
. set-java.sh 8
bazel test //polygerrit-ui/app:lint_test --test_output errors
bazel test //polygerrit-ui/app:polylint_test --test_output errors
fi
- shell: |
#!/bin/bash -xe
cd gerrit
if ([ "$TARGET_BRANCH" == "master" ] || [ "$TARGET_BRANCH" == "stable-3.0" ] || [ "$TARGET_BRANCH" == "stable-2.16" ] || [ "$TARGET_BRANCH" == "stable-2.15" ]) && git show --diff-filter=AM --name-only --pretty="" HEAD | grep polygerrit-ui
then
echo 'Running PolyGerrit template test...'
. set-java.sh 8
bazel test //polygerrit-ui/app:all --test_tag_filters=template --test_output errors
fi
- shell: |
#!/bin/bash -e
echo 'Running buildifier check...'
. set-java.sh 8
buildifier --version
cd gerrit
EXITCODE=0
for buildfile in $((git show --diff-filter=AM --name-only --pretty="" HEAD | grep --regex "WORKSPACE\|BUILD\|\.bzl$") || true)
do
BUILDIFIER_OUTPUT_FILE="$(mktemp)_buildifier_output.log"
buildifier -showlog -v -mode=check $buildfile 2>&1 | tee ${BUILDIFIER_OUTPUT_FILE}
if [[ -s ${BUILDIFIER_OUTPUT_FILE} ]]; then
echo "Need Formatting:"
echo "[$buildfile]"
echo "Please fix manually or run buildifier $buildfile to auto-fix."
buildifier -showlog -v -mode=diff $buildfile
rm -rf ${BUILDIFIER_OUTPUT_FILE}
EXITCODE=1
fi
done
exit $EXITCODE
- job:
name: 'Gerrit-verifier-change'
project-type: flow
concurrent: true
needs-workspace: true
node: master
parameters:
- string:
name: CHANGE_ID
description: Gerrit Change-ID to build and verify
scm:
- git:
url: https://gerrit.googlesource.com/gerrit
branches:
- "*/master"
submodule:
disable: true
skip-tag: true
dsl:
!include-raw: gerrit-verifier-change.groovy
properties:
- build-discarder:
days-to-keep: 7
- inject:
keep-build-variables: true
keep-system-variables: true
- job:
name: 'Gerrit-verifier-flow'
concurrent: true
project-type: flow
triggers:
- timed: 'H/5 * * * *'
dsl:
!include-raw: gerrit-verifier-flow.groovy
properties:
- build-discarder:
days-to-keep: 1