-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
50 lines (50 loc) · 1.58 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
pipeline {
agent any
stages {
stage('unit test') {
steps {
sh 'mvn clean test -P unit-tests'
}
}
stage('integration test') {
steps {
sh 'mvn clean test -P integration-tests'
}
}
stage('package') {
steps {
sh 'mvn -B -DskipTests clean package'
}
}
stage('build image') {
environment {
IMAGE_VERSION = sh (returnStdout: true, script: "grep '^version=' ./target/maven-archiver/pom.properties | cut -d '=' -f 2")
}
steps {
sh 'docker build -t edsonmendes/finances-api:${IMAGE_VERSION} -t edsonmendes/finances-api .'
}
}
stage('login dockerhub') {
environment {
DOCKERHUB_CREDENTIALS = credentials('edsonmendes-dockerhub')
}
steps {
sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin'
}
}
stage('push image') {
environment {
IMAGE_VERSION = sh (returnStdout: true, script: "grep '^version=' ./target/maven-archiver/pom.properties | cut -d '=' -f 2")
}
steps {
sh 'docker push edsonmendes/finances-api:${IMAGE_VERSION}'
sh 'docker push edsonmendes/finances-api:latest'
}
post {
always {
sh 'docker logout'
}
}
}
}
}