forked from xchem/fragalysis-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
74 lines (59 loc) · 2.07 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
#!groovy
// The 'xchem' Fragalysis Loader Jenkinsfile.
pipeline {
agent { label 'buildah-slave' }
environment {
// Local registry details (for FROM image)
REGISTRY_USER = 'jenkins'
REGISTRY = 'docker-registry.default.svc:5000'
STREAM_IMAGE = "${REGISTRY}/fragalysis-cicd/fragalysis-loader:latest"
// Slack channel for all notifications
SLACK_BUILD_CHANNEL = 'dls-builds'
// Slack channel to be used for errors/failures
SLACK_ALERT_CHANNEL = 'dls-alerts'
}
stages {
stage('Build Image') {
steps {
slackSend channel: "#${SLACK_BUILD_CHANNEL}",
message: "${JOB_NAME} build ${BUILD_NUMBER} - starting..."
script {
TOKEN = sh(script: 'oc whoami -t', returnStdout: true).trim()
}
sh "buildah bud --tls-verify=false --creds=${REGISTRY_USER}:${TOKEN} --format docker -f Dockerfile-cicd -t ${STREAM_IMAGE} ."
}
}
stage('Push Image') {
steps {
script {
TOKEN = sh(script: 'oc whoami -t', returnStdout: true).trim()
}
sh "podman login --tls-verify=false --username ${REGISTRY_USER} --password ${TOKEN} ${REGISTRY}"
sh "buildah push --tls-verify=false ${STREAM_IMAGE} docker://${STREAM_IMAGE}"
sh "podman logout ${REGISTRY}"
}
}
}
// Post-job actions.
// See https://jenkins.io/doc/book/pipeline/syntax/#post
post {
success {
slackSend channel: "#${SLACK_BUILD_CHANNEL}",
color: 'good',
message: "${JOB_NAME} build ${BUILD_NUMBER} - complete"
}
failure {
slackSend channel: "#${SLACK_BUILD_CHANNEL}",
color: 'danger',
message: "${JOB_NAME} build ${env.BUILD_NUMBER} - failed (${BUILD_URL})"
slackSend channel: "#${SLACK_ALERT_CHANNEL}",
color: 'danger',
message: "${JOB_NAME} build ${BUILD_NUMBER} - failed (${BUILD_URL})"
}
fixed {
slackSend channel: "#${env.SLACK_ALERT_CHANNEL}",
color: 'good',
message: "${JOB_NAME} build - fixed"
}
}
}