-
Notifications
You must be signed in to change notification settings - Fork 4
/
jenkinsfile
65 lines (58 loc) · 1.59 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
#!groovy
@Library('jenkinslib') _
def tools = new org.devops.tools()
String buildType = "${env.buildType}"
String buildShell = "${env.buildShell}"
String deployHosts = "${env.deployHosts}"
String srcUrl = "${env.srcUrl}"
String branchName = "${env.branchName}"
//Pipeline
pipeline {
agent {
label 'slave1'
}
options {
timestamps() //日志会有时间
skipDefaultCheckout() //删除隐式checkout scm语句
disableConcurrentBuilds() //禁止并行
timeout(time: 1, unit: 'HOURS') //流水线超时设置1h
}
stages {
//下载代码
stage("下载代码") { //阶段名称
steps { //步骤
script {
tools.PrintMes("获取代码", "green")
tools.checkOut(srcUrl, branchName)
}
}
}
//代码扫描
stage("代码扫描") {
steps {
script {
tools.PrintMes("代码扫描", "green")
tools.sonarScan(buildType)
}
}
}
//代码扫描
stage("构建代码") {
steps {
script {
tools.PrintMes("构建代码", "green")
tools.build(buildType, buildShell)
}
}
}
//部署扫描
stage("部署代码") {
steps {
script {
tools.PrintMes("部署代码", "green")
tools.deploy(deployHosts)
}
}
}
}
}