-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
166 lines (100 loc) · 5.59 KB
/
Jenkinsfile
File metadata and controls
166 lines (100 loc) · 5.59 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
pipeline {
agent any
tools {
gradle 'gradle'
jdk 'jdk11'
}
stages {
stage('git checkout'){
steps{
checkout([$class: 'GitSCM',
userRemoteConfigs: [[url: 'http://10.0.0.5:3000/test/ch8_4.git']],
branches: [[name: '*/main']],
extensions: [[$class: 'CheckoutOption', timeout: 10]]
])
}
}// git checkout end
stage('build project'){
steps{
sh 'gradle build'
sh 'pwd'
sh 'ls'
}// steps end
}// build project end
stage('mock test stage'){
steps{
sh 'gradle test'
}//steps end
}//mock test end
stage('checkstyle stage'){
steps{
sh 'gradle check'
}//steps end
}//checkstyle stage end
stage('sonarqube stage'){
steps{
sh 'curl 10.0.0.10:9000'
script {
def scannerHome = tool 'sonarscanner'
withEnv([
"SCANNERHOME=$scannerHome"
]){
withSonarQubeEnv("sonarserver"){
sh '''$SCANNERHOME/bin/sonar-scanner \
-Dsonar.projectKey=backend \
-Dsonar.projectName=backend \
-Dsonar.projectVersion=1.0 \
-Dsonar.sources=src \
-Dsonar.jacoco.reportsPath=build/jacoco/test.exec \
-Dsonar.java.checkstyle.reportPaths=build/reports/checkstyle/test.xml \
-Dsonar.java.binaries=build/libs/ch8_4-0.0.1-SNAPSHOT-plain.jar'''
}//withSonarQube end
}//withEnv
}// script end
}//sonar step end
}//sonarqube end
stage('Quality Gate'){
steps{
timeout(time: 1, unit: 'MINUTES'){
waitForQualityGate abortPipeline: true
}
}
}// quality gate end
stage('Publish Over SSH') {
steps{
sshPublisher(publishers: [sshPublisherDesc(configName: 'ansible',
transfers: [
sshTransfer(cleanRemote: false,
excludes: '',
execCommand: '',
execTimeout: 240000,
flatten: false,
makeEmptyDirs: false,
noDefaultExcludes: false,
patternSeparator: '[, ]+',
remoteDirectory: 'projects/backend',
remoteDirectorySDF: false,
removePrefix: '',
sourceFiles: 'app.jar'),
sshTransfer(cleanRemote: false, excludes: '',
execCommand: '''cd /home/azureuser/projects/backend
ansible-playbook backend-ci.yml > result
rm -rf Dockerfile app.jar''',
execTimeout: 240000,
flatten: false,
makeEmptyDirs: false,
noDefaultExcludes: false,
patternSeparator: '[, ]+',
remoteDirectory: 'projects/backend',
remoteDirectorySDF: false,
removePrefix: '',
sourceFiles: 'Dockerfile')],
usePromotionTimestamp: false,
useWorkspaceInPromotion: false,
verbose: false)]
)
build job: 'backend_cd_pipeline'
}// steps end
} //publish over ssh end
}//stages end
}// pipeline end