-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
78 lines (71 loc) · 2.27 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
// Define the pipeline
pipeline {
// This pipeline can be run on any Jenkins agent
agent any
// Define environment variables
environment {
// Define the home directory for SonarScanner
MSBuildScannerHome = tool 'SonarScanner for MSBuild v5'
}
// Define the stages of the pipeline
stages {
// Stage for beginning SonarQube analysis
stage('Begin SonarQube Analysis') {
steps {
// Skip this build if the commit message contains [CI-SKIP]
scmSkip(deleteBuild: true, skipPattern:'.*\\[CI-SKIP\\].*')
script {
// Set SonarQube environment variables
withSonarQubeEnv() {
// Begin SonarQube analysis
sh "dotnet ${MSBuildScannerHome}/SonarScanner.MSBuild.dll begin /k:\"panosru_CleanDDDArchitecture\""
}
}
}
}
// Stage for building the project
stage('Building') {
steps {
// Skip this build if the commit message contains [CI-SKIP]
scmSkip(deleteBuild: true, skipPattern:'.*\\[CI-SKIP\\].*')
// Restore dependencies and tools for the project
sh 'dotnet restore Aviant.sln'
// Build the project
sh "dotnet build"
}
}
// Stage for completing SonarQube analysis
stage('Complete SonarQube Analysis') {
steps {
// Skip this build if the commit message contains [CI-SKIP]
scmSkip(deleteBuild: true, skipPattern:'.*\\[CI-SKIP\\].*')
script {
// Set SonarQube environment variables
withSonarQubeEnv() {
// End SonarQube analysis
sh "dotnet ${MSBuildScannerHome}/SonarScanner.MSBuild.dll end"
}
}
}
}
// Stage for checking the SonarQube Quality Gate status
stage('Quality Gate') {
steps {
// Skip this build if the commit message contains [CI-SKIP]
scmSkip(deleteBuild: true, skipPattern:'.*\\[CI-SKIP\\].*')
echo 'Waiting for quality gate to pass'
timeout(time: 2, unit: 'MINUTES') {
waitForQualityGate abortPipeline: true
}
}
}
}
post {
cleanup {
catchError(buildResult: null, stageResult: 'FAILURE', message: 'Cleanup Failure') {
echo 'Cleaning up workspace...'
cleanWs()
}
}
}
}