format clean up stage

Former-commit-id: 29cd25f823901ecd46fd174fa26ddb57ef3c3620
This commit is contained in:
quicksilver 2019-07-14 14:43:47 +08:00
parent 56db76ce6b
commit f2eb4ca504
7 changed files with 98 additions and 206 deletions

View File

@ -1,11 +1,5 @@
try { try {
sh "helm del --purge ${env.JOB_NAME}-${env.BUILD_NUMBER}" sh "helm del --purge ${env.JOB_NAME}-${env.BUILD_NUMBER}"
if (currentBuild.result == 'ABORTED') {
throw new hudson.AbortException("Dev Test Aborted !")
} else if (currentBuild.result == 'FAILURE') {
error("Dev Test Failure !")
}
} catch (exc) { } catch (exc) {
sh "helm del --purge ${env.JOB_NAME}-${env.BUILD_NUMBER}" sh "helm del --purge ${env.JOB_NAME}-${env.BUILD_NUMBER}"
updateGitlabCommitStatus name: 'Cleanup Dev', state: 'failed' updateGitlabCommitStatus name: 'Cleanup Dev', state: 'failed'

View File

@ -1,11 +1,5 @@
try { try {
sh "helm del --purge ${env.JOB_NAME}-${env.BUILD_NUMBER}-cluster" sh "helm del --purge ${env.JOB_NAME}-${env.BUILD_NUMBER}-cluster"
if (currentBuild.result == 'ABORTED') {
throw new hudson.AbortException("Cluster Dev Test Aborted !")
} else if (currentBuild.result == 'FAILURE') {
error("Dev Test Failure !")
}
} catch (exc) { } catch (exc) {
sh "helm del --purge ${env.JOB_NAME}-${env.BUILD_NUMBER}-cluster" sh "helm del --purge ${env.JOB_NAME}-${env.BUILD_NUMBER}-cluster"
updateGitlabCommitStatus name: 'Cleanup Dev', state: 'failed' updateGitlabCommitStatus name: 'Cleanup Dev', state: 'failed'

View File

@ -9,8 +9,8 @@ container('milvus-testframework') {
} }
} catch (exc) { } catch (exc) {
updateGitlabCommitStatus name: 'Dev Test', state: 'failed' updateGitlabCommitStatus name: 'Dev Test', state: 'failed'
currentBuild.result = 'FAILURE'
echo 'Milvus Test Failed !' echo 'Milvus Test Failed !'
throw exc
} }
} }
} }

View File

@ -9,8 +9,8 @@ container('milvus-testframework') {
} }
} catch (exc) { } catch (exc) {
updateGitlabCommitStatus name: 'Dev Test', state: 'failed' updateGitlabCommitStatus name: 'Dev Test', state: 'failed'
currentBuild.result = 'FAILURE'
echo 'Milvus Test Failed !' echo 'Milvus Test Failed !'
throw exc
} }
} }
} }

View File

@ -191,38 +191,22 @@ spec:
} }
} }
} }
} post {
always {
stage ("Cleanup Dev") { stage ("Cleanup Dev") {
agent { agent {
kubernetes { kubernetes {
label 'jenkins-slave' label 'jenkins-slave'
defaultContainer 'jnlp' defaultContainer 'jnlp'
} }
} }
stages { stages {
stage('Cleanup') { gitlabCommitStatus(name: 'Cleanup Dev') {
steps { script {
gitlabCommitStatus(name: 'Cleanup Dev') { load "${env.WORKSPACE}/ci/jenkinsfile/cleanup_dev.groovy"
script { }
load "${env.WORKSPACE}/ci/jenkinsfile/cleanup_dev.groovy"
} }
} }
}
}
}
post {
aborted {
script {
updateGitlabCommitStatus name: 'Cleanup Dev', state: 'canceled'
echo "Milvus Cleanup Dev aborted !"
}
}
failure {
script {
updateGitlabCommitStatus name: 'Cleanup Dev', state: 'failed'
echo "Milvus Cleanup Dev failure !"
} }
} }
} }
@ -290,38 +274,22 @@ spec:
} }
} }
} }
} post {
always {
stage ("Cleanup Dev") { stage ("Cleanup Dev") {
agent { agent {
kubernetes { kubernetes {
label 'jenkins-slave' label 'jenkins-slave'
defaultContainer 'jnlp' defaultContainer 'jnlp'
} }
} }
stages { stages {
stage('Cleanup') { gitlabCommitStatus(name: 'Cleanup Dev') {
steps { script {
gitlabCommitStatus(name: 'Cleanup Dev') { load "${env.WORKSPACE}/ci/jenkinsfile/cluster_cleanup_dev.groovy"
script { }
load "${env.WORKSPACE}/ci/jenkinsfile/cluster_cleanup_dev.groovy"
} }
} }
}
}
}
post {
aborted {
script {
updateGitlabCommitStatus name: 'Cleanup Dev', state: 'canceled'
echo "Milvus Cleanup Dev aborted !"
}
}
failure {
script {
updateGitlabCommitStatus name: 'Cleanup Dev', state: 'failed'
echo "Milvus Cleanup Dev failure !"
} }
} }
} }
@ -375,4 +343,3 @@ spec:
} }
} }
} }

View File

@ -191,38 +191,22 @@ spec:
} }
} }
} }
} post {
always {
stage ("Cleanup Dev") { stage ("Cleanup Dev") {
agent { agent {
kubernetes { kubernetes {
label 'jenkins-slave' label 'jenkins-slave'
defaultContainer 'jnlp' defaultContainer 'jnlp'
} }
} }
stages { stages {
stage('Cleanup') { gitlabCommitStatus(name: 'Cleanup Dev') {
steps { script {
gitlabCommitStatus(name: 'Cleanup Dev') { load "${env.WORKSPACE}/ci/jenkinsfile/cleanup_dev.groovy"
script { }
load "${env.WORKSPACE}/ci/jenkinsfile/cleanup_dev.groovy"
} }
} }
}
}
}
post {
aborted {
script {
updateGitlabCommitStatus name: 'Cleanup Dev', state: 'canceled'
echo "Milvus Cleanup Dev aborted !"
}
}
failure {
script {
updateGitlabCommitStatus name: 'Cleanup Dev', state: 'failed'
echo "Milvus Cleanup Dev failure !"
} }
} }
} }
@ -290,38 +274,22 @@ spec:
} }
} }
} }
} post {
always {
stage ("Cleanup Dev") { stage ("Cleanup Dev") {
agent { agent {
kubernetes { kubernetes {
label 'jenkins-slave' label 'jenkins-slave'
defaultContainer 'jnlp' defaultContainer 'jnlp'
} }
} }
stages { stages {
stage('Cleanup') { gitlabCommitStatus(name: 'Cleanup Dev') {
steps { script {
gitlabCommitStatus(name: 'Cleanup Dev') { load "${env.WORKSPACE}/ci/jenkinsfile/cluster_cleanup_dev.groovy"
script { }
load "${env.WORKSPACE}/ci/jenkinsfile/cluster_cleanup_dev.groovy"
} }
} }
}
}
}
post {
aborted {
script {
updateGitlabCommitStatus name: 'Cleanup Dev', state: 'canceled'
echo "Milvus Cleanup Dev aborted !"
}
}
failure {
script {
updateGitlabCommitStatus name: 'Cleanup Dev', state: 'failed'
echo "Milvus Cleanup Dev failure !"
} }
} }
} }
@ -337,16 +305,18 @@ spec:
post { post {
always { always {
script { script {
if (!currentBuild.resultIsBetterOrEqualTo('SUCCESS')) { if (env.gitlabAfter != null) {
// Send an email only if the build status has changed from green/unstable to red if (!currentBuild.resultIsBetterOrEqualTo('SUCCESS')) {
emailext subject: '$DEFAULT_SUBJECT', // Send an email only if the build status has changed from green/unstable to red
body: '$DEFAULT_CONTENT', emailext subject: '$DEFAULT_SUBJECT',
recipientProviders: [ body: '$DEFAULT_CONTENT',
[$class: 'DevelopersRecipientProvider'], recipientProviders: [
[$class: 'RequesterRecipientProvider'] [$class: 'DevelopersRecipientProvider'],
], [$class: 'RequesterRecipientProvider']
replyTo: '$DEFAULT_REPLYTO', ],
to: '$DEFAULT_RECIPIENTS' replyTo: '$DEFAULT_REPLYTO',
to: '$DEFAULT_RECIPIENTS'
}
} }
} }
} }
@ -373,4 +343,3 @@ spec:
} }
} }
} }

View File

@ -191,38 +191,23 @@ spec:
} }
} }
} }
}
stage ("Cleanup Dev") { post {
agent { always {
kubernetes { stage ("Cleanup Dev") {
label 'jenkins-slave' agent {
defaultContainer 'jnlp' kubernetes {
} label 'jenkins-slave'
} defaultContainer 'jnlp'
stages { }
stage('Cleanup') { }
steps { stages {
gitlabCommitStatus(name: 'Cleanup Dev') { gitlabCommitStatus(name: 'Cleanup Dev') {
script { script {
load "${env.WORKSPACE}/ci/jenkinsfile/cleanup_dev.groovy" load "${env.WORKSPACE}/ci/jenkinsfile/cleanup_dev.groovy"
}
} }
} }
}
}
}
post {
aborted {
script {
updateGitlabCommitStatus name: 'Cleanup Dev', state: 'canceled'
echo "Milvus Cleanup Dev aborted !"
}
}
failure {
script {
updateGitlabCommitStatus name: 'Cleanup Dev', state: 'failed'
echo "Milvus Cleanup Dev failure !"
} }
} }
} }
@ -290,38 +275,22 @@ spec:
} }
} }
} }
} post {
always {
stage ("Cleanup Dev") { stage ("Cleanup Dev") {
agent { agent {
kubernetes { kubernetes {
label 'jenkins-slave' label 'jenkins-slave'
defaultContainer 'jnlp' defaultContainer 'jnlp'
} }
} }
stages { stages {
stage('Cleanup') { gitlabCommitStatus(name: 'Cleanup Dev') {
steps { script {
gitlabCommitStatus(name: 'Cleanup Dev') { load "${env.WORKSPACE}/ci/jenkinsfile/cluster_cleanup_dev.groovy"
script { }
load "${env.WORKSPACE}/ci/jenkinsfile/cluster_cleanup_dev.groovy"
} }
} }
}
}
}
post {
aborted {
script {
updateGitlabCommitStatus name: 'Cleanup Dev', state: 'canceled'
echo "Milvus Cleanup Dev aborted !"
}
}
failure {
script {
updateGitlabCommitStatus name: 'Cleanup Dev', state: 'failed'
echo "Milvus Cleanup Dev failure !"
} }
} }
} }
@ -373,4 +342,3 @@ spec:
} }
} }
} }