-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
64 lines (49 loc) · 1.5 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
54
55
56
57
58
59
60
61
62
63
64
#!groovy
pipeline {
agent any
triggers {
githubPush()
}
tools {
jdk 'AdoptOpenJDK 11 (LTS)'
}
environment {
AUTHOR = 'Insung Choi'
VERSION = "${GIT_BRANCH}_${GIT_COMMIT}"
}
stages {
stage('git status') {
steps {
echo "GIT_BRANCH=${GIT_BRANCH}"
echo "GIT_COMMIT=${GIT_COMMIT}"
echo "VERSION=${VERSION}"
}
}
stage('spring jar build') {
steps {
sh 'mvn clean package spring-boot:repackage'
echo "spring jar build complete"
}
}
stage('build docker image') {
steps {
def username = "${USERNAME}"
def password = "${PASSWORD}"
def apiService = 'api-service'
def appkeyService = 'appkey-service'
def configServer = 'config-server'
def gateway = 'gateway'
docker_build_push projectname: apiService, username:username, password:password
docker_build_push projectname: appkeyService, username:username, password:password
docker_build_push projectname: configServer, username:username, password:password
docker_build_push projectname: gateway, username:username, password:password
echo "docker image build and push complete"
}
}
}
}
void docker_build_push(buildinfo) {
echo "buildinfo ${buildinfo} "
sh "mvn -pl ${buildinfo.projectname} docker:build docker:push \"-Ddocker.username=${buildinfo.username}\" \"-Ddocker.password=${buildinfo.password}\""
echo "docker images ${buildinfo.projectname} pushed"
}