-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathJenkinsfile-candidate
55 lines (45 loc) · 1.43 KB
/
Jenkinsfile-candidate
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
#!groovy
properties([
parameters ([
string(
name: "VERSION",
defaultValue: "",
description: "Release candidate version tag"
),
string(
name: "BRANCH",
defaultValue: "",
description: "Specify the GitHub branch from which the image will be built"
)
])
])
node {
load "$JENKINS_HOME/jobvars.env"
dir('src/github.com/reportportal/service-index') {
stage('Checkout') {
checkout scm
}
stage('Build Docker Image') {
withEnv(["VERSION=${VERSION}", "AWS_URI=${AWS_URI}"]) {
sh 'make IMAGE_NAME=${AWS_URI}/service-index build-image v=${VERSION}-RC-$BUILD_NUMBER'
sh 'docker image tag ${AWS_URI}/service-index:latest ${AWS_URI}/service-index:${VERSION}-RC-$BUILD_NUMBER'
}
}
stage('Push to ECR') {
withEnv(["AWS_URI=${AWS_URI}", "AWS_REGION=${AWS_REGION}", "VERSION=${VERSION}"]) {
def image = env.AWS_URI + '/service-index:' + env.VERSION + '-RC-' + env.BUILD_NUMBER
def url = 'https://' + env.AWS_URI
def credentials = 'ecr:' + env.AWS_REGION + ':aws_credentials'
docker.withRegistry(url, credentials) {
docker.image(image).push()
}
}
}
stage('Cleanup') {
withEnv(["AWS_URI=${AWS_URI}"]) {
sh 'docker rmi ${AWS_URI}/service-index:${VERSION}-RC-${BUILD_NUMBER}'
sh 'docker rmi ${AWS_URI}/service-index:latest'
}
}
}
}