-
Notifications
You must be signed in to change notification settings - Fork 1
/
pipeline-script.grovvy
99 lines (95 loc) · 3.8 KB
/
pipeline-script.grovvy
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
#!groovy
pipeline {
agent any
parameters {
//git代码路径【参数值对外隐藏】
string(name:'repoUrl', defaultValue: 'https://github.com/surpass/surpass.github.io', description: 'git代码路径')
//repoBranch参数后续替换成git parameter不再依赖手工输入,JENKINS-46451【git parameters目前还不支持pipeline】
string(name:'repoBranch', defaultValue: '*/master', description: 'git分支名称')
string(name:'BUILD_USER_EMAIL', defaultValue: '[email protected]', description: '默认通知邮件')
}
tools {
maven 'maven3'
}
environment{
//git服务全系统只读账号cred_id【参数值对外隐藏】
CRED_ID='surpass1'
//测试人员邮箱地址【参数值对外隐藏】
QA_EMAIL='*****@*****.com'
//接口测试(网络层)的job名,一般由测试人员编写
ITEST_JOBNAME='Guahao_InterfaceTest_ExpertPatient'
}
post{
success{
script {
//需要安装 Build User Vars Plugin
wrap([$class: 'BuildUser']) {
mail to: "${BUILD_USER_EMAIL }",
subject: "PineLine '${JOB_NAME}' (${BUILD_NUMBER}) result",
body: "${BUILD_USER}'s pineline '${JOB_NAME}' (${BUILD_NUMBER}) run success\n请及时前往${env.BUILD_URL}进行查看"
}
}
}
failure{
script {
wrap([$class: 'BuildUser']) {
mail to: "${BUILD_USER_EMAIL }",
subject: "PineLine '${JOB_NAME}' (${BUILD_NUMBER}) result",
body: "${BUILD_USER}'s pineline '${JOB_NAME}' (${BUILD_NUMBER}) run failure\n请及时前往${env.BUILD_URL}进行查看"
}
}
}
unstable{
script {
wrap([$class: 'BuildUser']) {
mail to: "${BUILD_USER_EMAIL }",
subject: "PineLine '${JOB_NAME}' (${BUILD_NUMBER})结果",
body: "${BUILD_USER}'s pineline '${JOB_NAME}' (${BUILD_NUMBER}) run unstable\n请及时前往${env.BUILD_URL}进行查看"
}
}
}
}
stages {
stage('build user') {
steps {
wrap([$class: 'BuildUser']) {
sh 'echo "${BUILD_USER}"'
}
}
}
stage("Stage1") {
steps {
checkout([$class: 'GitSCM', branches: [[name: repoBranch]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: CRED_ID, url: repoUrl]]])
}
}
stage("并行执行的 Stage") {
parallel {
stage("Stage2.1统译静态网站") {
steps {
timestamps {
sh 'sh /var/jenkins_home/workspace/easyolap.cn/build.sh'
sleep 1
sh 'sh /var/jenkins_home/workspace/easyolap.cn/deploy.sh'
}
}
}
stage("Stage2.2同步到github") {
steps {
timestamps {
echo "在 agent test3 上执行的并行任务 2."
sleep 10
echo "在 agent test3 上执行的并行任务 2 结束."
}
}
}
}
}
stage("Stage3") {
steps {
timestamps {
echo "这是最后一个被执行的 stage."
}
}
}
}
}