1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-14 11:57:37 +00:00
kube-arangodb/Jenkinsfile.groovy

112 lines
3.5 KiB
Groovy
Raw Normal View History

2018-02-20 10:28:55 +00:00
def notifySlack(String buildStatus = 'STARTED') {
// Build status of null means success.
buildStatus = buildStatus ?: 'SUCCESS'
def color
if (buildStatus == 'STARTED') {
color = '#D4DADF'
} else if (buildStatus == 'SUCCESS') {
color = '#BDFFC3'
} else if (buildStatus == 'UNSTABLE') {
color = '#FFFE89'
} else {
color = '#FF9FA1'
}
def msg = "${buildStatus}: `${env.JOB_NAME}` #${env.BUILD_NUMBER}: ${env.GIT_COMMIT}\n${env.BUILD_URL}"
slackSend(color: color, channel: '#status-k8s', message: msg)
}
def kubeConfigRoot = "/home/jenkins/.kube/"
def buildTestSteps(String kubeconfig) {
return {
timestamps {
lock("${kubeconfig}-${params.TESTNAMESPACE}-${env.GIT_COMMIT}") {
withCredentials([string(credentialsId: 'ENTERPRISEIMAGE', variable: 'DEFAULTENTERPRISEIMAGE')]) {
withEnv([
"ENTERPRISEIMAGE=${params.ENTERPRISEIMAGE}",
"IMAGETAG=${env.GIT_COMMIT}",
"KUBECONFIG=${kubeConfigRoot}/${kubeconfig}",
"LONG=${params.LONG ? 1 : 0}",
"PUSHIMAGES=1",
"TESTNAMESPACE=${params.TESTNAMESPACE}-${env.GIT_COMMIT}",
]) {
sh "make run-tests"
}
}
}
}
}
}
def buildCleanupSteps(String kubeconfig) {
return {
timestamps {
2018-03-08 12:07:42 +00:00
withEnv([
"KUBECONFIG=${kubeConfigRoot}/${kubeconfig}",
"TESTNAMESPACE=${params.TESTNAMESPACE}-${env.GIT_COMMIT}",
]) {
sh "make cleanup-tests"
}
}
}
}
2018-02-20 10:28:55 +00:00
pipeline {
options {
buildDiscarder(logRotator(daysToKeepStr: '7', numToKeepStr: '10'))
}
agent any
parameters {
2018-03-01 10:15:18 +00:00
booleanParam(name: 'LONG', defaultValue: false, description: 'Execute long running tests')
string(name: 'KUBECONFIGS', defaultValue: 'scw-183a3b,c11', description: 'KUBECONFIGS is a comma separated list of Kubernetes configuration files (relative to /home/jenkins/.kube) on which the tests are run', )
string(name: 'TESTNAMESPACE', defaultValue: 'jenkins', description: 'TESTNAMESPACE sets the kubernetes namespace to ru tests in (this must be short!!)', )
2018-02-27 08:30:00 +00:00
string(name: 'ENTERPRISEIMAGE', defaultValue: '', description: 'ENTERPRISEIMAGE sets the docker image used for enterprise tests)', )
2018-02-20 10:28:55 +00:00
}
stages {
stage('Build') {
steps {
timestamps {
2018-02-20 17:53:33 +00:00
withEnv([
2018-02-22 10:19:28 +00:00
"IMAGETAG=${env.GIT_COMMIT}",
2018-02-20 17:53:33 +00:00
]) {
sh "make"
2018-02-27 14:32:09 +00:00
sh "make run-unit-tests"
2018-02-20 17:53:33 +00:00
}
2018-02-20 10:28:55 +00:00
}
}
}
stage('Test') {
2018-03-08 12:10:25 +00:00
//steps {
def configs = "{params.KUBECONFIGS}".split(",")
2018-03-08 12:08:47 +00:00
def testTasks = [:]
for (kubeconfig in configs) {
testTasks["${kubeconfig}"] = buildTestSteps(kubeconfig)
2018-02-20 10:28:55 +00:00
}
parallel testTasks
2018-03-08 12:10:25 +00:00
//}
2018-02-20 10:28:55 +00:00
}
}
post {
2018-02-27 10:31:27 +00:00
always {
def configs = "{params.KUBECONFIGS}".split(",")
2018-03-08 12:08:47 +00:00
def cleanupTasks = [:]
for (kubeconfig in configs) {
cleanupTasks["${kubeconfig}"] = buildCleanupSteps(kubeconfig)
2018-02-27 10:31:27 +00:00
}
parallel cleanupTasks
2018-02-27 10:31:27 +00:00
}
2018-02-20 10:28:55 +00:00
failure {
notifySlack('FAILURE')
}
success {
notifySlack('SUCCESS')
}
}
}