Repository navigation
Expand file tree
/
Copy pathJenkinsFile
More file actions
84 lines (80 loc) · 3.02 KB
/
Copy pathJenkinsFile
File metadata and controls
84 lines (80 loc) · 3.02 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
81
82
83
84
// Define all variables
PROGRAM_VERSION = "0.0.0.0" // default string for the version of the program
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '10'))
disableConcurrentBuilds()
disableResume()
copyArtifactPermission('/Lumos Installer (Pipeline)/*');
}
agent {
node{
label 'Win10'
}
}
environment {
// Define the VisualStudio tools
MSBuild = tool 'MSBuild VS Current'
VSTestConsole = tool 'VSTest VS Current'
// 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 DeskLamp-WinClient.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}\" DeskLamp-WinClient.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}\" DeskLamp-WinClient.sln /p:Configuration=Release /t:Clean;Rebuild /p:Platform=\"Any CPU\" "
}
}
}
stage('Readout Program Version'){
steps {
script {
// Read the version number out of the main assembly to use it for the installer builder
PROGRAM_VERSION_TOKENIZED = powershell(returnStdout: true, script: "([System.Reflection.Assembly]::LoadFrom(\"${WORKSPACE}/DeskLamp-WinClient/bin/Release/DeskLamp-WinClient.exe\").GetName().Version.ToString())").trim().tokenize(".")
PROGRAM_VERSION = PROGRAM_VERSION_TOKENIZED[0] + '.' + PROGRAM_VERSION_TOKENIZED[1] + '.' + PROGRAM_VERSION_TOKENIZED[3] + '.' + PROGRAM_VERSION_TOKENIZED[2]
}
}
}
stage('Pack Zip and Archive Artifacts'){
steps {
// Zip the release output and archive it
zip zipFile: "DeskLamp-WinClient_${PROGRAM_VERSION}.zip", archive: false, dir: 'DeskLamp-WinClient/bin/Release'
archiveArtifacts artifacts: "DeskLamp-WinClient_${PROGRAM_VERSION}.zip", fingerprint: true
}
}
}
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)
}
}
}