-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsFile
96 lines (92 loc) · 3.19 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '10'))
disableConcurrentBuilds()
disableResume()
copyArtifactPermission('');
}
agent {
node{
label 'Win10'
}
}
environment {
// Define the VisualStudio tools
MSBuild = tool 'MSBuild VS 2019'
VSTestConsole = tool 'VSTest VS 2019'
// Define the additional tools
SZip = tool '7Zip_current'
WGET = tool 'WGet_current'
CLOC = tool 'CLOC_current'
OpenCover = tool 'OpenCover_current'
ReportGenerator = tool 'ReportGenerator_current'
commitHash = bat (returnStdout: true, script: "@git log -n 1 --pretty=format:%%H").trim()
}
stages{
stage('Count Lines of Code'){
steps {
// Run the tool to count the code lines
bat "\"${CLOC}\" --by-file --xml --out=CountLinesOfCode/CLOCReport.xml --exclude-dir=Dependencies --include-lang=C# ."
}
}
stage('Update Nuget Packages'){
steps {
// First, update all nuget packages in the branch
bat 'nuget restore DeskLamp.sln'
}
}
stage('Build Debug Configuration'){
steps {
echo "Git Commit Hash is ${commitHash}"
echo "Build Number is ${env.BUILD_NUMBER}"
// Build the current branch in debug mode
bat "\"${MSBuild}\" DeskLamp.sln /p:Configuration=Debug /t:Clean;Rebuild /p:Platform=\"Any CPU\" "
}
}
stage('Build Release Configuration'){
steps {
script {
// Build the release configuration of the current branch
bat "\"${MSBuild}\" DeskLamp.sln /p:Configuration=Release /p:DefineConstants=\"JENKINS\" /t:Clean;Rebuild /p:Platform=\"Any CPU\" "
}
}
}
stage('Pack and Publish NuGet Package Internally'){
when { not {buildingTag() } }
steps {
script {
// Run the NuGet Publisher Worker Job to pack and publish the artifacts
build job:'_worker-NuGet-Publisher', parameters: [
string(name: 'WS_PATH', value: "${WORKSPACE}"),
string(name: 'PRJ_FILE', value: "DeskLamp.csproj" ),
[$class: 'NodeParameterValue', name: 'BUILD_NODE', labels: ["${env.NODE_NAME}"], nodeEligibility: [$class: 'AllNodeEligibility']]]
}
}
}
stage('Pack and Publish Package on Public NuGet'){
when { buildingTag() }
steps {
script {
// Run the NuGet Publisher Worker Job to pack and publish the artifacts (only, if this build is tagged)
build job:'_worker-NuGet-Publisher', parameters: [
string(name: 'WS_PATH', value: "${WORKSPACE}"),
string(name: 'PRJ_FILE', value: "DeskLamp.csproj" ),
booleanParam(name: 'USE_DMXC_NUGET', value: false),
[$class: 'NodeParameterValue', name: 'BUILD_NODE', labels: ["${env.NODE_NAME}"], nodeEligibility: [$class: 'AllNodeEligibility']]]
}
}
}
}
post {
always {
// Publish the CLOC report and msBuild issues
sloccountPublish encoding: 'UTF-8', pattern: 'CountLinesOfCode/CLOCReport.xml'
recordIssues tool: msBuild()
}
success {
// Run the post build processes only, if the build was a success because the the following steps need the output of the jobs so far
recordIssues tool: taskScanner(highTags:'FIXME', normalTags:'TODO', includePattern: '**/*.cs', IgnoreCase: true)
archiveArtifacts artifacts: 'DeskLampTest/bin/Debug/net6.0/*.*', fingerprint: true
}
}
}