Notify and fail job if minikube is not running
@@ -6,12 +6,30 @@ pipeline {
environment {
SERVICE = 'ocpmetal/assisted-service'
ISO_CREATION = 'assisted-iso-create'
+ SLACK_TOKEN = credentials('slack-token')
}
options {
timeout(time: 1, unit: 'HOURS')
}
stages {
+ stage('Check environment') {
+ steps {
+ sh '''
+ if [ $(minikube status|grep Running)="" ] ; then
+ echo "minikube is not running on $NODE_NAME, failing job BUILD_URL"
+ echo '{"text":"minikube is not running on: ' > minikube_data.txt
+ echo ${NODE_NAME} >> minikube_data.txt
+ echo 'failing job: ' >> minikube_data.txt
+ echo ${BUILD_URL} >> minikube_data.txt
+ echo '"}' >> minikube_data.txt
+ curl -X POST -H 'Content-type: application/json' --data-binary "@minikube_data.txt" https://hooks.slack.com/services/$SLACK_TOKEN
+ sh "exit 1"
+ fi
+ '''
+ }
+ }
+
stage('clear deployment') {
steps {
sh 'docker image prune -a -f'
@@ -74,17 +92,12 @@ pipeline {
failure {
script {
if (env.BRANCH_NAME == 'master')
- stage('notify master branch fail') {
- withCredentials([string(credentialsId: 'slack-token', variable: 'TOKEN')]) {
sh '''
echo '{"text":"Attention! assisted-service master branch subsystem test failed, see: ' > data.txt
-
echo ${BUILD_URL} >> data.txt
echo '"}' >> data.txt
- curl -X POST -H 'Content-type: application/json' --data-binary "@data.txt" https://hooks.slack.com/services/$TOKEN'''
-
- }
- }
+ curl -X POST -H 'Content-type: application/json' --data-binary "@data.txt" https://hooks.slack.com/services/$SLACK_TOKEN
+ '''
}
echo 'Get assisted-service log'
