-
Notifications
You must be signed in to change notification settings - Fork 0
/
JenkinsFile
113 lines (109 loc) · 5.72 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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 2022'
VSTestConsole = tool 'VSTest VS 2022'
// Define the additional tools
CLOC = tool 'CLOC_current'
OpenCover = tool 'OpenCover_current'
ReportGenerator = tool 'ReportGenerator_current'
}
triggers {
// Trigger, when Lumos build was successful
upstream (
threshold: hudson.model.Result.SUCCESS,
upstreamProjects: "/Lumos (Pipeline)/" + env.BRANCH_NAME.replaceAll("/", "%2F")
)
}
stages{
stage('Copy Artefacts of other Jobs'){
steps {
// Fetch all needed artifacts
script{
try {
println('Copy Kernel artefacts from Job \"Lumos (Pipeline)/' + env.BRANCH_NAME.replaceAll("/", "%2F") + '\"')
copyArtifacts(projectName: 'Lumos (Pipeline)/' + env.BRANCH_NAME.replaceAll("/", "%2F"), flatten: true, filter: 'Lumos/*', target: 'dep');
} catch (hudson.AbortException e) {
println('Job \"Lumos (Pipeline)/' + env.BRANCH_NAME.replaceAll("/", "%2F") + '\" does not exist. Copy from default Job')
copyArtifacts(projectName: 'Lumos (Pipeline)/master', flatten: true, filter: 'Lumos/*', target: 'dep');
}
try {
println('Copy GUI artefacts from Job \"Lumos (Pipeline)/' + env.BRANCH_NAME.replaceAll("/", "%2F") + '\"')
copyArtifacts(projectName: 'Lumos (Pipeline)/' + env.BRANCH_NAME.replaceAll("/", "%2F"), flatten: true, filter: 'LumosGUI/*', target: 'dep');
} catch (hudson.AbortException e) {
println('Job \"Lumos (Pipeline)/' + env.BRANCH_NAME.replaceAll("/", "%2F") + '\" does not exist. Copy from default Job')
copyArtifacts(projectName: 'Lumos (Pipeline)/master', flatten: true, filter: 'LumosGUI/*', target: 'dep');
}
}
}
}
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 Nanoleaf-Plugin.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}\" Nanoleaf-Plugin.sln /p:Configuration=Debug /t:Clean;Rebuild /p:Platform=\"Any CPU\";PreBuildEvent=;PostBuildEvent= "
}
}
stage('Build Release Configuration'){
steps {
script {
// Build the release configuration of the project
bat "\"${MSBuild}\" Nanoleaf-Plugin.sln /p:Configuration=Release /t:Clean;Rebuild /p:Platform=\"Any CPU\";PreBuildEvent=;PostBuildEvent= "
}
}
}
stage('Archive Artifacts'){
steps {
bat "xcopy \"$WORKSPACE\\Nanoleaf-Plugin\\bin\\Release\\net6.0\\Nanoleaf-Plugin.dll\" \"$WORKSPACE\\output\\\" /F /R /Y /I"
bat "xcopy \"$WORKSPACE\\Nanoleaf-Plugin\\bin\\Release\\net6.0\\Nanoleaf-Plugin.pdb\" \"$WORKSPACE\\output\\\" /F /R /Y /I"
bat "xcopy \"$WORKSPACE\\Nanoleaf-Plugin\\bin\\Release\\net6.0\\NanoleafAPI.dll\" \"$WORKSPACE\\output\\dependencies\\\" /F /R /Y /I"
bat "xcopy \"$WORKSPACE\\Nanoleaf-Plugin\\bin\\Release\\net6.0\\SSDP.UPnP.PCL.dll\" \"$WORKSPACE\\output\\dependencies\\\" /F /R /Y /I"
bat "xcopy \"$WORKSPACE\\Nanoleaf-Plugin\\bin\\Release\\net6.0\\ISSDP.UPnP.PCL.dll\" \"$WORKSPACE\\output\\dependencies\\\" /F /R /Y /I"
bat "xcopy \"$WORKSPACE\\Nanoleaf-Plugin\\bin\\Release\\net6.0\\SimpleHttpListener.Rx.dll\" \"$WORKSPACE\\output\\dependencies\\\" /F /R /Y /I"
bat "xcopy \"$WORKSPACE\\Nanoleaf-Plugin\\bin\\Release\\net6.0\\ISimpleHttpListener.Rx.dll\" \"$WORKSPACE\\output\\dependencies\\\" /F /R /Y /I"
bat "xcopy \"$WORKSPACE\\Nanoleaf-Plugin\\bin\\Release\\net6.0\\HttpMachine.dll\" \"$WORKSPACE\\output\\dependencies\\\" /F /R /Y /I"
bat "xcopy \"$WORKSPACE\\Nanoleaf-Plugin\\bin\\Release\\net6.0\\IHttpMachine.dll\" \"$WORKSPACE\\output\\dependencies\\\" /F /R /Y /I"
bat "xcopy \"$WORKSPACE\\Nanoleaf-Plugin\\bin\\Release\\net6.0\\Zeroconf.dll\" \"$WORKSPACE\\output\\dependencies\\\" /F /R /Y /I"
bat "xcopy \"$WORKSPACE\\Nanoleaf-Plugin\\bin\\Release\\net6.0\\System.*\" \"$WORKSPACE\\output\\dependencies\\\" /F /R /Y /I"
bat "xcopy \"$WORKSPACE\\Nanoleaf-Plugin\\bin\\Release\\net6.0\\Microsoft.*\" \"$WORKSPACE\\output\\dependencies\\\" /F /R /Y /I"
bat "xcopy \"$WORKSPACE\\NanoleafGUI-Plugin\\bin\\Release\\net48\\NanoleafGUI-Plugin.dll\" \"$WORKSPACE\\output\\\" /F /R /Y /I"
bat "xcopy \"$WORKSPACE\\NanoleafGUI-Plugin\\bin\\Release\\net48\\NanoleafGUI-Plugin.pdb\" \"$WORKSPACE\\output\\\" /F /R /Y /I"
bat "xcopy \"$WORKSPACE\\NanoleafGUI-Plugin\\bin\\Release\\net48\\Newtonsoft.Json.dll\" \"$WORKSPACE\\output\\dependencies\\\" /F /R /Y /I"
bat "xcopy \"$WORKSPACE\\NanoleafGUI-Plugin\\bin\\Release\\net48\\System.ComponentModel.Annotations.dll\" \"$WORKSPACE\\output\\dependencies\\\" /F /R /Y /I"
dir('output') {
archiveArtifacts artifacts: '**/*.*'
}
}
}
}
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)
}
}
}