forked from openshift/assisted-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
59 lines (54 loc) · 1.97 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
52
53
54
55
56
57
58
59
String cron_string = BRANCH_NAME == "master" ? "@daily" : ""
pipeline {
agent { label 'centos_worker' }
triggers { cron(cron_string) }
environment {
INSTALLER = 'quay.io/ocpmetal/assisted-installer'
CONTROLLER = 'quay.io/ocpmetal/assisted-installer-controller'
}
options {
timeout(time: 1, unit: 'HOURS')
}
stages {
stage('build') {
steps {
sh 'skipper make'
}
}
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 ${INSTALLER} ${INSTALLER}:latest'''
sh '''docker tag ${INSTALLER} ${INSTALLER}:${GIT_COMMIT}'''
sh '''docker push ${INSTALLER}:latest'''
sh '''docker push ${INSTALLER}:${GIT_COMMIT}'''
sh '''docker tag ${CONTROLLER} ${CONTROLLER}:latest'''
sh '''docker tag ${CONTROLLER} ${CONTROLLER}:${GIT_COMMIT}'''
sh '''docker push ${CONTROLLER}:latest'''
sh '''docker push ${CONTROLLER}:${GIT_COMMIT}'''
}
}
}
post {
failure {
script {
if (env.BRANCH_NAME == 'master')
stage('notify master branch fail') {
withCredentials([string(credentialsId: 'slack-token', variable: 'TOKEN')]) {
sh '''
echo '{"text":"Attention! assisted-installer 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
'''
}
}
}
}
}
}