-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-docker.groovy
57 lines (52 loc) · 1.62 KB
/
deploy-docker.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
45
46
47
48
49
50
51
52
53
54
55
56
57
pipeline {
agent any
tools {
maven 'Maven'
jdk 'JDK8'
}
options{
gitLabConnection('gitlab')
}
stages {
stage('Preparation') {
steps {
script {
git(
url: 'CHANGE_GIT_URL',
credentialsId: 'CHANGE_GITLAB_CREDENTIALS',
branch: "${BRANCH_NAME}"
)
}
}
}
stage('Build') {
steps {
timeout(30) {
ansiColor('xterm') {
script {
try {
sh "mvn clean install -DskipTests -Pbuild-docker-image"
}catch(error){
junit '**/target/*-reports/*.xml'
}
}
}
}
}
}
stage('Deploy') {
steps {
timeout(30) {
ansiColor('xterm') {
script {
sh 'docker --version'
sh 'cd docker && docker build -t CHANGE_IMAGE_TAG --build-arg JAR_FILE=CHANGE_YOUR_JAR_FILE .'
sh 'docker stop CHANGE_CONTAINER_NAME || true && docker rm CHANGE_CONTAINER_NAME || true'
sh 'docker run -p 8080:8080 --name CHANGE_CONTAINER_NAME -d -t CHANGE_IMAGE_TAG'
}
}
}
}
}
}
}