This repository has been archived by the owner on Aug 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Jenkinsfile
104 lines (94 loc) · 2.79 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
pipeline {
agent any
environment {
image = ''
}
tools {
maven 'M3'
}
stages {
stage('Poll') {
steps {
checkout scm
}
}
stage('Build') {
steps {
sh 'mvn -B -DskipTests clean package'
archiveArtifacts 'target/*.jar'
}
}
stage('Unit test') {
steps {
sh 'mvn test -DskipITs=true'
}
post {
always {
junit '**/target/surefire-reports/*.xml'
}
}
}
stage('Integration test') {
steps {
sh 'mvn test -Dsurefire.skip=true'
}
post {
always {
junit testResults: '**/target/failsafe-reports/*.xml', allowEmptyResults: true
}
}
}
stage('Build Docker Image') {
steps {
script {
image = docker.build('cyj199637/sns-itda')
}
}
}
stage('Push Docker Image') {
steps {
script{
docker.withRegistry('https://registry.hub.docker.com/', 'docker-hub') {
image.push('latest')
}
}
}
}
stage('Remove Docker Image') {
steps {
sh 'docker rmi cyj199637/sns-itda'
sh 'docker rmi registry.hub.docker.com/cyj199637/sns-itda:latest'
}
}
stage('Deploy') {
steps([$class: 'BapSshPromotionPublisherPlugin']) {
sshPublisher(
continueOnError: false, failOnError: true,
publishers: [
sshPublisherDesc(
configName: "server-deploy",
verbose: true,
transfers: [
sshTransfer(
sourceFiles: "",
removePrefix: "",
remoteDirectory: "",
execCommand: "sh ~/scripts/deploy-docker.sh"
)
]
)
]
)
}
}
}
post {
failure {
mail to: "cyj199637@gmail.com",
subject: "FAILURE: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]'",
body: """
Check console output at "<a href="${env.BUILD_URL}">${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]</a>"
"""
}
}
}