mirror of
https://github.com/valitydev/salt.git
synced 2024-11-06 16:45:27 +00:00
9ef9206520
This should actually cause builds to fail when any part in the try block fails. We still delete instances and try junit rendering, but if things fail then they get marked on github as failed.
83 lines
4.6 KiB
Plaintext
83 lines
4.6 KiB
Plaintext
timeout(time: 6, unit: 'HOURS') {
|
|
node('kitchen-slave') {
|
|
timestamps {
|
|
ansiColor('xterm') {
|
|
withEnv([
|
|
'SALT_KITCHEN_PLATFORMS=/var/jenkins/workspace/platforms.yml',
|
|
'SALT_KITCHEN_DRIVER=/var/jenkins/workspace/driver.yml',
|
|
'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=windows-2016',
|
|
'PY_COLORS=1',
|
|
]) {
|
|
stage('checkout-scm') {
|
|
cleanWs notFailBuild: true
|
|
checkout scm
|
|
}
|
|
try {
|
|
stage('github-pending') {
|
|
githubNotify credentialsId: 'test-jenkins-credentials',
|
|
description: "running ${TEST_SUITE}-${TEST_PLATFORM}...",
|
|
status: 'PENDING',
|
|
context: "jenkins/pr/${TEST_SUITE}-${TEST_PLATFORM}"
|
|
}
|
|
stage('setup-bundle') {
|
|
sh 'bundle install --with ec2 windows --without opennebula docker'
|
|
}
|
|
try {
|
|
stage('run kitchen') {
|
|
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'
|
|
}
|
|
}
|
|
}
|
|
} 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'
|
|
}
|
|
}
|
|
}
|
|
archiveArtifacts artifacts: 'artifacts/xml-unittests-output/*.xml'
|
|
archiveArtifacts artifacts: 'artifacts/logs/minion'
|
|
archiveArtifacts artifacts: 'artifacts/logs/salt-runtests.log'
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
currentBuild.result = 'FAILURE'
|
|
} finally {
|
|
try {
|
|
junit 'artifacts/xml-unittests-output/*.xml'
|
|
} finally {
|
|
cleanWs notFailBuild: true
|
|
def currentResult = currentBuild.result ?: 'SUCCESS'
|
|
if (currentResult == 'SUCCESS') {
|
|
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}"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|