forked from reportportal/migrations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
47 lines (36 loc) · 1.45 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
#!groovy
node {
load "$JENKINS_HOME/jobvars.env"
stage('Checkout') {
checkout scm
}
stage('Build') {
docker.withServer("$DOCKER_HOST") {
withEnv(["AWS_URI=${AWS_URI}", "AWS_REGION=${AWS_REGION}"]) {
stage('Build Docker Image') {
sh 'docker build -t reportportal-dev/db-scripts -t ${AWS_URI}/migrations .'
}
stage('Run Migrations') {
sh "docker-compose -p reportportal -f $COMPOSE_FILE_RP run --rm migrations up"
}
stage('Push to ECR') {
sh 'docker tag reportportal-dev/db-scripts ${AWS_URI}/migrations'
def image = env.AWS_URI + '/migrations'
def url = 'https://' + env.AWS_URI
def credentials = 'ecr:' + env.AWS_REGION + ':aws_credentials'
docker.withRegistry(url, credentials) {
docker.image(image).push('SNAPSHOT-${BUILD_NUMBER}')
}
}
stage('Cleanup') {
docker.withServer("$DOCKER_HOST") {
withEnv(["AWS_URI=${AWS_URI}"]) {
sh 'docker rmi ${AWS_URI}/migrations:SNAPSHOT-${BUILD_NUMBER}'
sh 'docker rmi ${AWS_URI}/migrations:latest'
}
}
}
}
}
}
}