-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
106 lines (105 loc) · 4.56 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
105
106
def gitUrl = "https://git.dpark.com.cn/git/sipsd-open-source/flowable_v4.git"
def branch = "master"
def credentialsId = "c078ac92-89dd-4842-8292-5e348e68db08"
def rootPath= "./sipsd-flowable-editor"
def appName = "flowable-editor"
def bakPath = "/home/jenkins_bak"
def putPath = "/home/jenkins_put"
def publishPath= "/usr/local/nginx/html/flowable-editor"
def robot = "360ac2ce-efe5-4478-8703-7cd3bd463044"
pipeline {
agent any
stages {
stage('拉取代码') {
steps {
git branch: "$branch", credentialsId: "$credentialsId", url: "$gitUrl"
}
}
stage('项目编译') {
steps {
script{
sh "cd ${rootPath} && yarn install && yarn run build"
}
}
}
stage('项目部署') {
steps {
script {
def remote = [:]
remote.name = 'remote'
remote.host ='192.168.126.25'
remote.user = 'root'
remote.password ='kjjsyf#0512'
remote.allowAnyHosts= true
stage ('备份') {
sshCommand remote: remote,command: "mkdir -p ${bakPath}/${appName}"
sshCommand remote: remote,command: "cp -r ${publishPath} ${bakPath}/${appName}/${BUILD_NUMBER}"
}
stage ('更新') {
sshCommand remote: remote,command: "mkdir -p ${putPath}/${appName}"
sshPut remote: remote,from: "${rootPath}/dist",into:"${putPath}/${appName}"
}
stage ('启动') {
sshCommand remote: remote,command: "rm -rf ${publishPath}"
sshCommand remote: remote,command: "mv ${putPath}/${appName}/dist ${publishPath}"
}
}
}
}
}
post {
success {
script {
dingtalk(robot: robot,
type: 'ACTION_CARD',
at: [],
atAll: false,
title: "",
text: [
"<font color=#0089ff >${appName}项目部署</font>",
"",
"----",
"",
"* 任务:#${BUILD_NUMBER}",
"* 项目:${appName}",
"* 状态:<font color=#00EE00 >部署成功</font>",
"* 持续时间:${currentBuild.durationString}".split("and counting")[0],
"* 执行人:${currentBuild.buildCauses.shortDescription}",
],
messageUrl: '',
picUrl: '',
singleTitle: '',
btns: [],
btnLayout: 'H',
hideAvatar: false
)
}
}
failure {
script {
dingtalk(robot: robot,
type: 'ACTION_CARD',
at: [],
atAll: false,
title: "",
text: [
"<font color=#0089ff >${appName}项目部署</font>",
"",
"----",
"",
"* 任务:#${BUILD_NUMBER}",
"* 项目:${appName}",
"* 状态:<font color=#EE0000 >部署失败</font>",
"* 持续时间:${currentBuild.durationString}".split("and counting")[0],
"* 执行人:${currentBuild.buildCauses.shortDescription}",
],
messageUrl: '',
picUrl: '',
singleTitle: '',
btnLayout: 'H',
hideAvatar: false
)
}
}
}
}