forked from InformaticsMatters/pipelines
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
90 lines (66 loc) · 2.82 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
79
80
81
82
83
84
85
86
87
88
89
90
#!groovy
// Part of the Squonk/OepnShift CI/CD Jenkins Pipeline.
//
// This is the primary CI/CD pipeline, which provides basic assembly,
// unit testing and Docker image construction. Other pipelines may offer
// static analysis and code coverage for example.
pipeline {
// As we may need different flavours of agent,
// the agent definition is deferred to each stage.
agent none
// Some environment variables for every stage...
environment {
USER = 'jenkins'
REGISTRY = 'docker-registry.default:5000'
NAMESPACE = 'squonk-cicd'
PIPELINES_IMAGE = 'rdkit_pipelines'
LOADER_IMAGE = "${PIPELINES_IMAGE}_loader"
TAG = 'latest'
P_IMAGE = "${NAMESPACE}/${PIPELINES_IMAGE}:${TAG}"
L_IMAGE = "${NAMESPACE}/${LOADER_IMAGE}:${TAG}"
}
stages {
// --------------------------------------------------------------------
// Deploy
// --------------------------------------------------------------------
stage ('Deploy') {
// Here we build and Deploy the docker images.
// We need a custom agent that's capable of building images.
agent {
label 'buildah-slave'
}
steps {
// Registry..
echo "Expecting registry at ${env.REGISTRY}"
echo "Expecting registry user ${env.USER}"
echo "Expecting registry project ${env.PUSH_NAMESPACE}"
// Expose tool versions...
sh 'buildah -v'
sh 'podman -v'
sh 'skopeo -v'
// Build...
// (Small image first)
sh "buildah bud --format docker -f Dockerfile-sdposter -t ${env.P_IMAGE} ."
sh "buildah bud --format docker -f Dockerfile-rdkit -t ${env.L_IMAGE} ."
// Deploy...
// Get user login token
script {
TOKEN = sh(script: 'oc whoami -t', returnStdout: true).trim()
}
// Login to the target registry, push images and logout
sh "podman login --tls-verify=false --username ${env.USER} --password ${TOKEN} ${env.REGISTRY}"
// sh "buildah push --tls-verify=false ${env.P_IMAGE} docker://${env.REGISTRY}/${env.P_IMAGE}"
// sh "buildah push --tls-verify=false ${env.L_IMAGE} docker://${env.REGISTRY}/${env.L_IMAGE}"
sh "podman logout ${env.REGISTRY}"
}
}
}
// End-of-pipeline post-processing actions...
post {
failure {
mail to: '[email protected] [email protected]',
subject: 'Failed Pipelines Job',
body: "Something is wrong with the Squonk CI/CD PIPELINES build ${env.BUILD_URL}"
}
}
}