forked from deepmalamittal89/app_deepmala
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
80 lines (71 loc) · 1.99 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
pipeline {
agent any
environment {
scannerHome = tool name: 'sonar_scanner_dotnet'
username = 'deepmalamittal'
}
options {
timestamps()
timeout(time: 1, unit: 'HOURS')
}
stages {
stage ("Nuget restore") {
steps {
echo "Restoring nuget packages"
sh "dotnet restore"
}
}
stage('Start sonarqube analysis'){
when {
branch "master"
}
steps {
withSonarQubeEnv('Test_Sonar') {
sh "dotnet ${scannerHome}/SonarScanner.MSBuild.dll begin /k:sonar-${userName} /n:sonar-${userName} /v:1.0"
}
}
}
stage('Code build') {
steps {
echo "Cleaning and building the code.."
sh "dotnet clean"
sh "dotnet build --configuration Release"
}
}
stage('Test case Execution') {
when {
branch "master"
}
steps {
echo "Execute test cases."
sh "dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover -l:trx;LogFileName=TestFileReport.xml"
}
}
stage('Stop sonarqube analysis'){
when {
branch "master"
}
steps {
echo "Stopping sonarqube analysis"
withSonarQubeEnv('Test_Sonar') {
sh "dotnet ${scannerHome}/SonarScanner.MSBuild.dll end"
}
}
}
stage ("Release artifact") {
when {
branch "develop"
}
steps {
echo "Releasing the artifact"
sh "dotnet publish --configuration Release"
}
}
stage('Kubernetes Deployment') {
steps{
echo "Initiating Kubernetes deployment"
sh "kubectl apply -f deployment.yaml"
}
}
}
}