forked from openshift/assisted-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
66 lines (61 loc) · 2.28 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
60
61
62
63
64
65
66
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'
}
post {
always {
junit '**/reports/*test.xml'
cobertura coberturaReportFile: '**/reports/*coverage.xml', onlyStable: false, enableNewApi: true
}
}
}
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 {
always {
script {
if ((env.BRANCH_NAME == 'master') && (currentBuild.currentResult == "ABORTED" || currentBuild.currentResult == "FAILURE")){
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
'''
}
}
}
}
}
}
}