-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathJenkinsfile
69 lines (56 loc) · 2.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
pipeline {
agent {
kubernetes {
yamlFile 'kubernetesPod.yaml'
}
}
options {
authorizationMatrix(['hudson.model.Item.Build:consultants', 'hudson.model.Item.Read:consultants'])
buildDiscarder(logRotator(numToKeepStr: '3'))
}
environment {
shortCommit = sh(returnStdout: true, script: "git log -n 1 --pretty=format:'%h'").trim()
IMAGE = "r-base"
NS = "openanalytics"
REG = "196229073436.dkr.ecr.eu-west-1.amazonaws.com"
VERSION = '4.0.5'
DOCKER_BUILDKIT = '1'
}
stages {
stage('Build openanalytics/r-base Docker'){
steps {
container('dind'){
withOARegistry {
sh """
docker build --build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from ${env.REG}/${env.NS}/${env.IMAGE}:latest \
-t ${env.NS}/${env.IMAGE}:${env.VERSION} \
-t ${env.NS}/${env.IMAGE}:${env.shortCommit} \
-t ${env.NS}/${env.IMAGE}:latest \
.
"""
}
}
}
}
}
post {
success {
container('dind'){
sh "echo tagging and pushing images to OA registry and Docker Hub"
withOARegistry {
ecrPush "${env.REG}", "${env.NS}/${env.IMAGE}", "latest", '', 'eu-west-1'
ecrPush "${env.REG}", "${env.NS}/${env.IMAGE}", "${env.VERSION}", '', 'eu-west-1'
ecrPush "${env.REG}", "${env.NS}/${env.IMAGE}", "${env.shortCommit}", '', 'eu-west-1'
}
withDockerRegistry([
credentialsId: "openanalytics-dockerhub",
url: ""]) {
sh "docker push ${env.NS}/${env.IMAGE}:${env.VERSION}"
sh "docker push ${env.NS}/${env.IMAGE}:${env.shortCommit}"
sh "docker push ${env.NS}/${env.IMAGE}:latest"
}
}
}
}
}