2019-05-29 12:51:43 +00:00
|
|
|
// Define the maximum time, in hours, that a test run should run for
|
|
|
|
def testrun_timeout = 6
|
|
|
|
// Now define a global pipeline timeout. This is the test run timeout with one(1) additional
|
|
|
|
// hour to allow for artifacts to be downloaded, if possible.
|
|
|
|
def global_timeout = testrun_timeout + 1;
|
|
|
|
|
2019-04-23 21:35:09 +00:00
|
|
|
properties([
|
2019-06-05 22:37:32 +00:00
|
|
|
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')),
|
2019-04-23 21:35:09 +00:00
|
|
|
[
|
|
|
|
$class: 'ScannerJobProperty', doNotScan: false
|
|
|
|
],
|
|
|
|
[
|
|
|
|
$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false
|
|
|
|
],
|
|
|
|
parameters([
|
2019-05-10 16:40:40 +00:00
|
|
|
booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull')
|
2019-04-23 21:35:09 +00:00
|
|
|
])
|
|
|
|
])
|
2019-05-29 12:51:43 +00:00
|
|
|
timeout(time: global_timeout, unit: 'HOURS') {
|
2018-09-28 19:31:58 +00:00
|
|
|
node('kitchen-slave') {
|
|
|
|
timestamps {
|
|
|
|
ansiColor('xterm') {
|
|
|
|
withEnv([
|
2019-04-07 13:48:11 +00:00
|
|
|
'SALT_KITCHEN_PLATFORMS=/var/jenkins/workspace/nox-platforms.yml',
|
|
|
|
'SALT_KITCHEN_VERIFIER=/var/jenkins/workspace/nox-verifier.yml',
|
2018-09-28 19:31:58 +00:00
|
|
|
'SALT_KITCHEN_DRIVER=/var/jenkins/workspace/driver.yml',
|
2019-04-07 13:48:11 +00:00
|
|
|
'NOX_ENV_NAME=runtests-zeromq',
|
|
|
|
'NOX_PASSTHROUGH_OPTS=--ssh-tests',
|
|
|
|
'NOX_ENABLE_FROM_FILENAMES=true',
|
2019-05-09 11:12:44 +00:00
|
|
|
'GOLDEN_IMAGES_CI_BRANCH=2019.2',
|
2019-04-07 13:48:11 +00:00
|
|
|
'CODECOV_FLAGS=centos7,py2',
|
2018-09-28 19:31:58 +00:00
|
|
|
'PATH=/usr/local/rbenv/shims/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin',
|
|
|
|
'RBENV_VERSION=2.4.2',
|
|
|
|
'TEST_SUITE=py2',
|
|
|
|
'TEST_PLATFORM=centos-7',
|
|
|
|
'PY_COLORS=1',
|
2019-04-23 21:35:09 +00:00
|
|
|
"FORCE_FULL=${params.runFull}",
|
2018-09-28 19:31:58 +00:00
|
|
|
]) {
|
2019-05-29 12:51:43 +00:00
|
|
|
// Set the GH status even before cloning the repo
|
|
|
|
stage('github-pending') {
|
|
|
|
githubNotify credentialsId: 'test-jenkins-credentials',
|
|
|
|
description: "running ${TEST_SUITE}-${TEST_PLATFORM}...",
|
|
|
|
status: 'PENDING',
|
|
|
|
context: "jenkins/pr/${TEST_SUITE}-${TEST_PLATFORM}"
|
|
|
|
}
|
|
|
|
// Checkout the repo
|
2018-09-28 19:31:58 +00:00
|
|
|
stage('checkout-scm') {
|
|
|
|
cleanWs notFailBuild: true
|
|
|
|
checkout scm
|
2018-09-25 16:09:20 +00:00
|
|
|
}
|
|
|
|
try {
|
2019-05-29 12:51:43 +00:00
|
|
|
// Setup the kitchen required bundle
|
2018-09-28 19:31:58 +00:00
|
|
|
stage('setup-bundle') {
|
2019-05-29 12:51:43 +00:00
|
|
|
sh 'bundle install --with ec2 windows --without docker macos opennebula vagrant'
|
2018-09-28 19:31:58 +00:00
|
|
|
}
|
|
|
|
try {
|
|
|
|
stage('run kitchen') {
|
2019-05-29 12:51:43 +00:00
|
|
|
timeout(time: testrun_timeout, unit: 'HOURS') {
|
|
|
|
withCredentials([
|
|
|
|
[$class: 'AmazonWebServicesCredentialsBinding', accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 'AWS_ACCESS_KEY_ID', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY']
|
|
|
|
]) {
|
|
|
|
sshagent(credentials: ['jenkins-testing-ssh-key']) {
|
|
|
|
sh 'ssh-add ~/.ssh/jenkins-testing.pem'
|
|
|
|
sh 'bundle exec kitchen converge $TEST_SUITE-$TEST_PLATFORM || bundle exec kitchen converge $TEST_SUITE-$TEST_PLATFORM'
|
|
|
|
sh 'bundle exec kitchen verify $TEST_SUITE-$TEST_PLATFORM'
|
|
|
|
}
|
2018-09-28 19:31:58 +00:00
|
|
|
}
|
2018-09-25 16:09:20 +00:00
|
|
|
}
|
|
|
|
}
|
2018-09-28 19:31:58 +00:00
|
|
|
} finally {
|
|
|
|
stage('cleanup kitchen') {
|
|
|
|
script {
|
|
|
|
withCredentials([
|
|
|
|
[$class: 'AmazonWebServicesCredentialsBinding', accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 'AWS_ACCESS_KEY_ID', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY']
|
|
|
|
]) {
|
|
|
|
sshagent(credentials: ['jenkins-testing-ssh-key']) {
|
|
|
|
sh 'ssh-add ~/.ssh/jenkins-testing.pem'
|
|
|
|
sh 'bundle exec kitchen destroy $TEST_SUITE-$TEST_PLATFORM'
|
|
|
|
}
|
|
|
|
}
|
2018-09-25 16:09:20 +00:00
|
|
|
}
|
2019-04-07 13:48:11 +00:00
|
|
|
archiveArtifacts artifacts: 'artifacts/*,artifacts/**/*'
|
|
|
|
}
|
|
|
|
stage('report code coverage') {
|
|
|
|
script {
|
|
|
|
withCredentials([[$class: 'StringBinding', credentialsId: 'codecov-upload-token-salt', variable: 'CODECOV_TOKEN']]) {
|
|
|
|
sh '''
|
2019-04-25 13:35:43 +00:00
|
|
|
if [ -n "${FORCE_FULL}" -a "${FORCE_FULL}" = "true" -a -f artifacts/coverage/coverage.xml ]; then
|
2019-04-07 13:48:11 +00:00
|
|
|
curl -L https://codecov.io/bash | /bin/sh -s -- -R $(pwd) -s artifacts/coverage/ -F "${CODECOV_FLAGS}"
|
|
|
|
fi
|
|
|
|
'''
|
|
|
|
}
|
|
|
|
}
|
2018-09-28 19:31:58 +00:00
|
|
|
}
|
|
|
|
}
|
2018-10-02 21:31:23 +00:00
|
|
|
} catch (Exception e) {
|
|
|
|
currentBuild.result = 'FAILURE'
|
2018-09-28 19:31:58 +00:00
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
junit 'artifacts/xml-unittests-output/*.xml'
|
|
|
|
} finally {
|
|
|
|
cleanWs notFailBuild: true
|
2019-05-27 07:10:09 +00:00
|
|
|
if (currentBuild.resultIsBetterOrEqualTo('SUCCESS')) {
|
2018-09-28 19:31:58 +00:00
|
|
|
githubNotify credentialsId: 'test-jenkins-credentials',
|
|
|
|
description: "The ${TEST_SUITE}-${TEST_PLATFORM} job has passed",
|
|
|
|
status: 'SUCCESS',
|
|
|
|
context: "jenkins/pr/${TEST_SUITE}-${TEST_PLATFORM}"
|
|
|
|
} else {
|
|
|
|
githubNotify credentialsId: 'test-jenkins-credentials',
|
|
|
|
description: "The ${TEST_SUITE}-${TEST_PLATFORM} job has failed",
|
|
|
|
status: 'FAILURE',
|
|
|
|
context: "jenkins/pr/${TEST_SUITE}-${TEST_PLATFORM}"
|
2019-04-11 10:53:45 +00:00
|
|
|
try {
|
|
|
|
slackSend channel: "#jenkins-prod-pr",
|
|
|
|
color: '#FF0000',
|
|
|
|
message: "FAILED: PR-Job: '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})"
|
|
|
|
} catch (Exception e) {
|
|
|
|
sh 'echo Failed to send the Slack notification'
|
|
|
|
}
|
2018-09-28 19:31:58 +00:00
|
|
|
}
|
2018-06-13 19:57:04 +00:00
|
|
|
}
|
2018-09-25 16:09:20 +00:00
|
|
|
}
|
|
|
|
}
|
2018-09-28 19:31:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-25 13:35:43 +00:00
|
|
|
|
|
|
|
// vi: ft=groovy
|