forked from zeyangli/jenkinslibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
desk.groovy
103 lines (84 loc) · 2.79 KB
/
desk.groovy
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
#!groovy
@Library('jenkinslib') _
def tools = new org.devops.tools()
String workspace = "/opt/jenkins/workspace"
//Pipeline
pipeline {
agent { node { label "master" //指定运行节点的标签或者名称
customWorkspace "${workspace}" //指定运行工作目录(可选)
}
}
options {
timestamps() //日志会有时间
skipDefaultCheckout() //删除隐式checkout scm语句
disableConcurrentBuilds() //禁止并行
timeout(time: 1, unit: 'HOURS') //流水线超时设置1h
}
stages {
//下载代码
stage("GetCode"){ //阶段名称
when { environment name: 'test', value: 'abcd' }
steps{ //步骤
timeout(time:5, unit:"MINUTES"){ //步骤超时时间
script{ //填写运行代码
println('获取代码')
println("${test}")
input id: 'Test', message: '我们是否要继续?', ok: '是,继续吧!', parameters: [choice(choices: ['a', 'b'], description: '', name: 'test1')], submitter: 'lizeyang,admin'
}
}
}
}
stage("01"){
failFast true
parallel {
//构建
stage("Build"){
steps{
timeout(time:20, unit:"MINUTES"){
script{
println('应用打包')
mvnHome = tool "m2"
println(mvnHome)
sh "${mvnHome}/bin/mvn --version"
}
}
}
}
//代码扫描
stage("CodeScan"){
steps{
timeout(time:30, unit:"MINUTES"){
script{
print("代码扫描")
tools.PrintMes("this is my lib!")
}
}
}
}
}
}
}
//构建后操作
post {
always {
script{
println("always")
}
}
success {
script{
currentBuild.description = "\n 构建成功!"
}
}
failure {
script{
currentBuild.description = "\n 构建失败!"
}
}
aborted {
script{
currentBuild.description = "\n 构建取消!"
}
}
}
}