This repository has been archived by the owner on Feb 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
65 lines (57 loc) · 2.24 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
pipeline {
agent any
parameters {
string(name: 'SONAR_LOGIN_KEY', defaultValue: '0616e8ac5902cfec9bc6ee009b1b8c375de6a3aa', description: 'Sonarqube logon key')
string(name: 'NUGET_PUSH_KEY', defaultValue: 'oy2nkpvkrxmkd3g6axdqhxzuzlxzreuebchf22q5ffvn7u', description: 'Nuget push key')
}
environment {
PRODUCT_NAME = 'OnixApi'
PUBLISH_FLAG = 'N'
BUILT_VERSION = '1.1.1-SNAPSHOT'
SONAR_SCANNER = '/home/tomcat/.dotnet/tools/dotnet-sonarscanner'
COVERLET = '/home/tomcat/.dotnet/tools/coverlet'
UNIT_TEST_ASSEMBLY = './tests/bin/Debug/netcoreapp2.2/OnixTest.dll'
PACKAGE_PATH = './sources/bin/Release'
BUILD_MODE = 'Release'
}
stages {
stage('Start Code Analysis') {
steps {
sh "${env.SONAR_SCANNER} begin \
/key:pjamenaja_onixapi \
/o:pjamenaja \
/v:${env.BUILT_VERSION} \
/d:sonar.host.url=https://sonarcloud.io \
/d:sonar.branch.name=${env.BRANCH_NAME} \
/d:sonar.cs.opencover.reportsPaths=./coverage.opencover.xml \
/d:sonar.login=${params.SONAR_LOGIN_KEY}"
sh "echo [${env.BUILT_VERSION}]"
}
}
stage('Build') {
steps {
sh "dotnet build -p:Version=${env.BUILT_VERSION}"
}
}
stage('Nuget Publish') {
when {
expression { env.PUBLISH_FLAG == 'Y' }
}
steps {
sh "dotnet nuget push ${env.PACKAGE_PATH}/${env.PRODUCT_NAME}.${env.BUILT_VERSION}.nupkg \
-k ${params.NUGET_PUSH_KEY} \
-s https://api.nuget.org/v3/index.json"
}
}
stage('Unit Test') {
steps {
sh "${env.COVERLET} ${env.UNIT_TEST_ASSEMBLY} --target 'dotnet' --targetargs 'test . --no-build' --format opencover"
}
}
stage('End Code Analysis') {
steps {
sh "${env.SONAR_SCANNER} end /d:sonar.login=${params.SONAR_LOGIN_KEY}"
}
}
}
}