forked from reportportal/service-api
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
53 lines (48 loc) · 1.86 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
#!groovy
node {
load "$JENKINS_HOME/jobvars.env"
env.JAVA_HOME = "${tool 'openjdk-11'}"
env.PATH = "${env.JAVA_HOME}/bin:${env.PATH}"
stage('Checkout') {
checkout scm
}
stage('Assemble') {
sh "./gradlew clean assemble -P buildNumber=${env.BUILD_NUMBER}"
}
stage('Test') {
sh './gradlew test --full-stacktrace'
}
stage('Build') {
sh './gradlew build'
}
stage('Docker image') {
sh "./gradlew buildDocker -P dockerServerUrl=$DOCKER_HOST"
}
stage('Deploy Container') {
docker.withServer("$DOCKER_HOST") {
sh "docker-compose -p reportportal -f $COMPOSE_FILE_RP up -d --force-recreate api"
stage('Push to registries') {
withEnv(["AWS_URI=${AWS_URI}", "AWS_REGION=${AWS_REGION}", "LOCAL_REGISTRY=${LOCAL_REGISTRY}"]) {
sh 'docker tag reportportal-dev/service-api ${AWS_URI}/service-api'
sh 'docker tag reportportal-dev/service-api ${LOCAL_REGISTRY}/service-api'
sh 'docker push ${LOCAL_REGISTRY}/service-api'
def image = env.AWS_URI + '/service-api'
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}", "LOCAL_REGISTRY=${LOCAL_REGISTRY}"]) {
sh 'docker rmi ${AWS_URI}/service-api:SNAPSHOT-${BUILD_NUMBER}'
sh 'docker rmi ${AWS_URI}/service-api:latest'
sh 'docker rmi ${LOCAL_REGISTRY}/service-api:latest'
}
}
}
}