forked from xchem/fragalysis-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
78 lines (62 loc) · 2 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
75
76
77
78
#!groovy
// The 'xchem' Fragalysis Backend Jenkinsfile.
pipeline {
agent { label 'buildah-slave' }
environment {
// Registry details
USER = 'jenkins'
REGISTRY = 'docker-registry.default.svc:5000'
STREAM_IMAGE = "${REGISTRY}/fragalysis-cicd/fragalysis-backend: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('Inspect') {
steps {
slackSend channel: "#${SLACK_BUILD_CHANNEL}",
message: "${JOB_NAME} build ${BUILD_NUMBER} - starting..."
echo "Inspecting..."
}
}
stage('Build Image') {
steps {
echo "Building fragalysis-backend..."
sh "buildah bud --format docker -f Dockerfile -t ${STREAM_IMAGE} ."
}
}
stage('Push Image') {
steps {
script {
TOKEN = sh(script: 'oc whoami -t', returnStdout: true).trim()
}
sh "podman login --tls-verify=false --username ${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: "#${SLACK_ALERT_CHANNEL}",
color: 'good',
message: "${JOB_NAME} build - fixed"
}
}
}