-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
123 lines (117 loc) · 4.54 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
pipeline {
agent none
tools{
maven 'maven3.5'
}
environment{
registry = "121.36.31.229:8595"
pingZheng = 'ddb40bf6-06ae-4728-881f-a8459909209a'
}
stages {
stage('拉取代码') {
agent {node {label 'master'}}
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '3179d59449a89e5a27c52003173267b7902bbfc2', url: 'https://github.com/xiexuejian/demo.git']]])
}
}
stage('单元测试'){
parallel{
stage('单元测试'){
agent {node {label 'master'}}
steps{
echo "单元测试开始。。。。"
sh "mvn org.jacoco:jacoco-maven-plugin:prepare-agent -f pom.xml clean test -Dautoconfig.skip=true -Dmaven.test.skip=false -Dmaven.test.failure.ignore=true"
junit '**/target/surefire-reports/*.xml'
jacoco changeBuildStatus: true, maximumLineCoverage: "70"
}
}
}
}
stage('代码质量检测') {
agent {node {label 'master'}}
steps {
dir(env.WORKSPACE){
sh "mvn sonar:sonar -Dsonar.host.url=http://121.36.31.229:9000 -Dsonar.login=f4a34690771d6da24bd3fa9a94f33eefa6cf05d8"
}
}
}
stage('开始构建') {
agent {node {label 'master'}}
steps {
dir(env.WORKSPACE){
sh "mvn clean install"
sh "printenv"
junit allowEmptyResults: true, keepLongStdio: true, testResults: 'target/**/*.xml'
sh "mv target/sample-0.0.1-SNAPSHOT.jar target/sample.jar"
}
}
}
stage('镜像'){
parallel{
stage('构建镜像并发布到Nexus') {
agent {node {label 'master'}}
steps{
withDockerRegistry([
credentialsId:"${pingZheng}",
url:"http://${registry}"
]){
sh "docker build -t ${registry}/jenkins:v3 ."
sh "docker push ${registry}/jenkins:v3"
}
}
}
stage('初始化docker环境') {
agent {node {label 'master'}}
steps {
script{
def dockerPath = tool 'docker19'
env.PATH = "${dockerPath}/bin:${env.PATH}"
}
}
}
}
}
}
post{
success {
dingtalk (
robot: '993af071-b4d3-4544-a2c2-0464e5cf6e48',
type: 'LINK',
title: '小爱同学提示:你有新的消息,请注意查收',
text: [
'人脸识别部署信息',
'可爱的小爱同学通知你,项目部署成功',
'工作人员可以点击登录Jenkins进行查看'
],
messageUrl: 'http://39.96.168.238:8888/',
picUrl: 'https://www.picdiet.com/img/photographer_compressed.jpg'
)
}
failure {
dingtalk (
robot: '993af071-b4d3-4544-a2c2-0464e5cf6e48',
type: 'ACTION_CARD',
title: '小爱同学提示:你有新的消息,请注意查收',
text: [
'![screenshot](@lADOpwk3K80C0M0FoA)',
'人脸识别部署信息',
'可爱的小爱同学通知你,项目部署失败',
'工作人员可以点击登录Jenkins进行查看'
],
messageUrl: 'http://39.96.168.238:8888/',
picUrl: 'https://www.picdiet.com/img/photographer_compressed.jpg',
btns: [
[
title: '内容不错',
actionUrl: 'https://www.dingtalk.com/'
],
[
title: '不感兴趣',
actionUrl: 'https://www.dingtalk.com/'
]
],
btnLayout: 'V'
)
}
}
}