-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
53 lines (53 loc) · 1.45 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
pipeline {
agent any
triggers {
GenericTrigger(
causeString: 'Triggered by develop',
genericVariables: [[key: 'ref', value: '$.ref']],
printContributedVariables: true,
printPostContent: true,
regexpFilterExpression: 'refs/heads/' + BRANCH_NAME,
regexpFilterText: 'refs/heads/dev',
token: 'abc123'
)
}
stages {
stage('maven build') {
steps {
sh 'mvn clean package'
}
}
stage('master deploy'){
when{
branch 'master'
}
steps{
sh 'mv target/*.jar web_test_master.jar'
script {
try {
sh "kill -9 \$(ps -ef|grep 'java -jar web_test_master.jar'|gawk '\$0 !~/grep/ {print \$2}' |tr -s '\n' ' ')"
} catch (err) {
echo "first run master"
}
}
sh 'nohup java -jar web_test_master.jar >/dev/null 2>&1 &'
}
}
stage('dev deploy'){
when{
branch 'dev'
}
steps{
sh 'mv target/*.jar web_test_dev.jar'
script {
try {
sh "kill -9 \$(ps -ef|grep 'java -jar web_test_dev.jar'|gawk '\$0 !~/grep/ {print \$2}' |tr -s '\n' ' ')"
} catch (err) {
echo "first run dev"
}
}
sh "nohup 'java -jar web_test_dev.jar >/dev/null 2>&1 &'"
}
}
}
}