-
Notifications
You must be signed in to change notification settings - Fork 0
/
JenkinsFile
95 lines (91 loc) · 3.69 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
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 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 AudioAnalyzer-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}\" AudioAnalyzer-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}\" AudioAnalyzer-Plugin.sln /p:Configuration=Release /t:Clean;Rebuild /p:Platform=\"Any CPU\";PreBuildEvent=;PostBuildEvent= "
}
}
}
stage('Archive Artifacts'){
steps {
bat "xcopy \"$WORKSPACE\\AudioAnalyzer-Plugin\\bin\\Release\\net48\\AudioAnalyzer-Plugin.dll\" \"$WORKSPACE\\output\\\" /F /R /Y /I"
bat "xcopy \"$WORKSPACE\\AudioAnalyzer-Plugin\\bin\\Release\\net48\\AudioAnalyzer-Plugin.dll.config\" \"$WORKSPACE\\output\\\" /F /R /Y /I"
bat "xcopy \"$WORKSPACE\\AudioAnalyzer-Plugin\\bin\\Release\\net48\\AudioAnalyzer-Plugin.pdb\" \"$WORKSPACE\\output\\\" /F /R /Y /I"
bat "xcopy \"$WORKSPACE\\AudioAnalyzer-Plugin\\bin\\Release\\net48\\Bass.Net.dll\" \"$WORKSPACE\\output\\dependencies\\\" /F /R /Y /I"
bat "xcopy \"$WORKSPACE\\AudioAnalyzer-Plugin\\bin\\Release\\net48\\bass.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)
}
}
}