-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
80 lines (73 loc) · 1.71 KB
/
Jenkinsfile
File metadata and controls
80 lines (73 loc) · 1.71 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
pipeline {
agent any
environment {
DOTNET_CLI_TELEMETRY_OPTOUT = '1'
SONAR_PROJECT_KEY = "LaundryReservationWebAPI"
}
stages {
stage('Checkout') {
steps {
echo 'Checking out source code from SCM...'
checkout scm
}
}
stage('SonarQube Analysis') {
steps {
withSonarQubeEnv('SonarQube') {
script {
bat "dotnet sonarscanner begin /k:${SONAR_PROJECT_KEY} /d:sonar.token=${SONAR_AUTH_TOKEN}"
bat "dotnet build"
bat "dotnet sonarscanner end /d:sonar.token=${SONAR_AUTH_TOKEN}"
}
}
}
}
stage('Restore') {
steps {
echo 'Restoring NuGet packages...'
script {
if (isUnix()) {
sh 'dotnet restore'
} else {
bat 'dotnet restore'
}
}
}
}
stage('Build') {
steps {
echo 'Building the solution...'
script {
if (isUnix()) {
sh 'dotnet build -c Release --no-restore'
} else {
bat 'dotnet build -c Release --no-restore'
}
}
}
}
stage('Test') {
steps {
echo 'Running tests...'
script {
if (isUnix()) {
sh 'dotnet test --no-build -c Release'
} else {
bat 'dotnet test --no-build -c Release'
}
}
}
}
}
post {
success {
echo 'Pipeline completed successfully!'
}
failure {
echo 'Pipeline failed!'
}
always {
archiveArtifacts artifacts: '**/bin/**', allowEmptyArchive: true
}
}
}