-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJenkinsFile
87 lines (83 loc) · 3.35 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
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '10'))
disableConcurrentBuilds()
disableResume()
copyArtifactPermission('/Lumos Installer (Pipeline)/*,/3Dconnexion Lumos Plugin (Pipeline)/*');
}
agent {
node{
label 'Win10'
}
}
environment {
// Define the VisualStudio tools
MSBuild = tool 'MSBuild VS 2022'
VSTestConsole = tool 'VSTest VS 2022'
// Define the additional tools
CLOC = tool 'CLOC_current'
OpenCover = tool 'OpenCover_current'
ReportGenerator = tool 'ReportGenerator_current'
}
triggers {
// Trigger once a week
cron('H H * * H')
}
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('Build Debug Configuration'){
steps {
// First update all nuget packages in the branch
bat 'nuget restore 3DconnexionDriver.sln'
// Then add the current build number in the version number and build the branch
changeAsmVer versionPattern: '$BUILD_NUMBER', regexPattern: '(Assembly(.*)Version\\("(.+)\\.(.+)\\.(.+)\\.(.+)")', replacementPattern: 'Assembly\$2Version("\$3.\$4.\$5.%s"'
bat "\"${MSBuild}\" 3DconnexionDriver.sln /p:Configuration=Debug /t:Clean;Rebuild /p:Platform=\"Any CPU\" "
}
}
stage('Build Release Configuration'){
steps {
script {
// Build the release configuration of the project
bat "\"${MSBuild}\" 3DconnexionDriver.sln /p:Configuration=Release /t:Clean;Rebuild /p:Platform=\"Any CPU\" "
}
}
}
stage('Pack and Publish Package on Public NuGet'){
steps {
script {
PROGRAM_VERSION_TOKENIZED = powershell(returnStdout: true, script: "(Get-Item \"bin/Release/netstandard2.0/3DconnexionDriver.dll\").VersionInfo.FileVersion").trim().tokenize(".")
PROGRAM_VERSION = PROGRAM_VERSION_TOKENIZED[0] + '.' + PROGRAM_VERSION_TOKENIZED[1] + '.' + PROGRAM_VERSION_TOKENIZED[2] + '.' + PROGRAM_VERSION_TOKENIZED[3]
// 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: "3DconnexionDriver.csproj" ),
string(name: 'VERSION', value: "${PROGRAM_VERSION}" ),
booleanParam(name: 'USE_DOTNET_PACK', value: true),
booleanParam(name: 'USE_DMXC_NUGET', value: false),
[$class: 'NodeParameterValue', name: 'BUILD_NODE', labels: ["${env.NODE_NAME}"], nodeEligibility: [$class: 'AllNodeEligibility']]]
}
}
}
stage('Archive Artifacts'){
steps {
archiveArtifacts artifacts: 'bin/Release/**/*.*'
}
}
}
post {
always {
// Publish the log of the build process
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 step needs the output of the jobs so far
recordIssues tool: taskScanner(highTags:'FIXME', normalTags:'TODO', includePattern: '**/*.cs', IgnoreCase: true)
}
}
}