-
Notifications
You must be signed in to change notification settings - Fork 13
/
Jenkinsfile.groovy
45 lines (36 loc) · 1.63 KB
/
Jenkinsfile.groovy
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
#!groovy
node {
load "$JENKINS_HOME/jobvars.env"
dir('src/github.com/reportportal/service-index') {
stage('Checkout'){
checkout scm
}
stage('Build Docker Image') {
sh """
MAJOR_VER=\$(cat VERSION)
BUILD_VER="\${MAJOR_VER}-${env.BUILD_NUMBER}"
make build-image v=\$BUILD_VER
"""
}
stage('Deploy container') {
stage('Push to ECR') {
withEnv(["AWS_URI=${AWS_URI}", "AWS_REGION=${AWS_REGION}"]) {
sh 'docker tag reportportal-dev/service-index ${AWS_URI}/service-index:SNAPSHOT-${BUILD_NUMBER}'
def image = env.AWS_URI + '/service-index' + ':SNAPSHOT-' + env.BUILD_NUMBER
def url = 'https://' + env.AWS_URI
def credentials = 'ecr:' + env.AWS_REGION + ':aws_credentials'
echo image
docker.withRegistry(url, credentials) {
docker.image(image).push()
}
}
}
}
stage('Cleanup') {
withEnv(["AWS_URI=${AWS_URI}"]) {
sh 'docker rmi ${AWS_URI}/service-index:SNAPSHOT-${BUILD_NUMBER}'
sh 'docker rmi reportportal-dev/service-index:latest'
}
}
}
}