def hdbPodTemplate(closure) { podTemplate( containers: [ containerTemplate(name: 'hdb', image: 'kgyrtkirk/hive-dev-box:executor', ttyEnabled: true, command: 'cat', alwaysPullImage: true, resourceRequestCpu: '1800m', resourceLimitCpu: '3000m', resourceRequestMemory: '6400Mi', resourceLimitMemory: '12000Mi' ), ], yaml:''' spec: securityContext: fsGroup: 1000 tolerations: - key: "type" operator: "Equal" value: "slave" effect: "PreferNoSchedule" - key: "type" operator: "Equal" value: "slave" effect: "NoSchedule" nodeSelector: type: slave ''') { closure(); } } def jobWrappers(closure) { timestamps { hdbPodTemplate { node(POD_LABEL) { container('hdb') { closure() } } } } } properties([ parameters([ string(name: "GITHUB_USER", defaultValue: 'apache', description: 'the github user to checkout the branch from'), string(name: "GITHUB_REPO", defaultValue: 'hive', description: 'this is usually hive - unless you'), string(name: "BRANCH", defaultValue: 'master', description: 'change to your branch name in case you are enabling back'), string(name: 'OPTS', defaultValue: '-pl shims/common -Dtest=TestHdfsUtils', description: 'maven options to run the test in question; please use -pl to reduce the scope to only the affected project'), ]) ]) def buildHive(args) { configFileProvider([configFile(fileId: 'artifactory', variable: 'SETTINGS')]) { withEnv(["MULTIPLIER=$params.MULTIPLIER","M_OPTS=$params.OPTS"]) { sh '''#!/bin/bash -e . /etc/profile.d/confs.sh export USER="`whoami`" export MAVEN_OPTS="-Xmx2g" export -n HIVE_CONF_DIR OPTS=" -s $SETTINGS -B -Dmaven.test.failure.ignore -Dtest.groups= " OPTS+=" -Pitests,qsplits" OPTS+=" -Dorg.slf4j.simpleLogger.log.org.apache.maven.plugin.surefire.SurefirePlugin=INFO" OPTS+=" -Dmaven.repo.local=$PWD/.git/m2" OPTS+=" $M_OPTS " if [ -s inclusions.txt ]; then OPTS+=" -Dsurefire.includesFile=$PWD/inclusions.txt";fi if [ -s exclusions.txt ]; then OPTS+=" -Dsurefire.excludesFile=$PWD/exclusions.txt";fi set -x mvn $OPTS '''+args+''' ''' } } } def updateDescription(status) { currentBuild.description = "$GITHUB_USER/$GITHUB_REPO[$BRANCH]\n$OPTS\n$status" } jobWrappers { updateDescription("checkout") checkout([ $class: 'GitSCM', branches: [[name: BRANCH]], userRemoteConfigs: [[url: 'https://github.com/$GITHUB_USER/$GITHUB_REPO']], extensions: [ [$class: 'CloneOption', shallow: true] ] ]) updateDescription("build") buildHive("install -DskipTests -am") for(int i=0;i<100;i++) { updateDescription("try#$i") sh("banner try#$i") def args="-Dsurefire.failIfNoSpecifiedTests -q" args+=" org.apache.maven.plugins:maven-antrun-plugin:run@{define-classpath,setup-test-dirs,setup-metastore-scripts}" args+=" org.apache.maven.plugins:maven-surefire-plugin:test" buildHive(args) } }