forked from openshift/assisted-ignition-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
51 lines (44 loc) · 1.51 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
pipeline {
environment {
GENERATOR = 'quay.io/ocpmetal/assisted-ignition-generator'
}
agent {
node {
label 'host'
}
}
stages {
stage('build') {
steps {
sh 'docker image prune -a -f'
sh 'make build-image'
}
}
stage('publish images on push to master') {
when {
branch 'master'
}
steps {
withCredentials([usernamePassword(credentialsId: 'ocpmetal_cred', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
sh '''docker login quay.io -u $USER -p $PASS'''
}
sh '''docker tag ${GENERATOR} ${GENERATOR}:latest'''
sh '''docker tag ${GENERATOR} ${GENERATOR}:${GIT_COMMIT}'''
sh '''docker push ${GENERATOR}:latest'''
sh '''docker push ${GENERATOR}:${GIT_COMMIT}'''
}
}
}
post {
failure {
script {
if (env.BRANCH_NAME == 'master')
stage('notify master branch fail') {
withCredentials([string(credentialsId: 'slack-token', variable: 'TOKEN')]) {
sh '''curl -X POST -H 'Content-type: application/json' --data '{"text":"Attention! master branch push integration failed, Check $BUILD_URL"}' https://hooks.slack.com/services/${TOKEN}'''
}
}
}
}
}
}