forked from openshift/assisted-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
74 lines (64 loc) · 2.19 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
67
68
69
70
71
72
73
74
String cron_string = BRANCH_NAME == "master" ? "@hourly" : ""
pipeline {
agent { label 'centos_worker' }
triggers { cron(cron_string) }
environment {
PATH = "${PATH}:/usr/local/go/bin"
// Images
SERVICE = "quay.io/ocpmetal/assisted-service:${BUILD_TAG}"
ISO_CREATION = "quay.io/ocpmetal/assisted-iso-create:${BUILD_TAG}"
// Credentials
SLACK_TOKEN = credentials('slack-token')
QUAY_IO_CREDS = credentials('ocpmetal_cred')
}
options {
timeout(time: 1, unit: 'HOURS')
}
stages {
stage('Init') {
steps {
sh 'make clear-all || true'
}
}
stage('Build') {
steps {
sh "make build-image build-minimal-assisted-iso-generator-image"
sh "make jenkins-deploy-for-subsystem"
sh "kubectl get pods -A"
}
}
stage('Subsystem Test') {
steps {
sh "make subsystem-run"
}
}
stage('Publish') {
when { branch 'master'}
steps {
sh "docker login quay.io -u ${QUAY_IO_CREDS_USR} -p ${QUAY_IO_CREDS_PSW}"
sh "make publish"
}
}
}
post {
failure {
script {
if (env.BRANCH_NAME == 'master') {
script {
def data = [text: "Attention! ${BUILD_TAG} job failed, see: ${BUILD_URL}"]
writeJSON(file: 'data.txt', json: data, pretty: 4)
}
sh '''curl -X POST -H 'Content-type: application/json' --data-binary "@data.txt" https://hooks.slack.com/services/${SLACK_TOKEN}'''
}
}
}
always {
script {
for (service in ["assisted-service","postgres","scality","createimage"]) {
sh "kubectl get pods -o=custom-columns=NAME:.metadata.name -A | grep ${service} | xargs -r -I {} sh -c \"kubectl logs {} -n assisted-installer > {}.log\" || true"
}
archiveArtifacts artifacts: '*.log', fingerprint: true
}
}
}
}