-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
52 lines (39 loc) · 1.39 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
pipeline {
agent any
parameters {
string(defaultValue: "",description: 'remote host password', name: 'sshPassword')
}
stages {
stage('Build') {
agent {
docker {
image 'maven:3.8.1-adoptopenjdk-11'
args '-v /root/.m2:/root/.m2'
reuseNode true
}
}
steps {
sh 'mvn -B -DskipTests clean package'
}
}
stage('build image'){
steps {
script {
docker.withRegistry( '', 'my-docker-credentials' ) {
dockerImage = docker.build 'mohaijiang/spring-boot-example'
dockerImage.push("$BUILD_NUMBER")
dockerImage.push('latest')
}
}
}
}
stage('Remote SSH') {
steps {
sh """
sshpass -p ${params.sshPassword} ssh -o "StrictHostKeyChecking no" [email protected] -p 22 docker rm -f spring-boot-example
sshpass -p ${params.sshPassword} ssh -o "StrictHostKeyChecking no" [email protected] -p 22 docker run -d -p 8080:8080 --name spring-boot-example mohaijiang/spring-boot-example:$BUILD_NUMBER
"""
}
}
}
}