-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathJenkinsfile
More file actions
100 lines (97 loc) · 3.14 KB
/
Jenkinsfile
File metadata and controls
100 lines (97 loc) · 3.14 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
properties(
[
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')),
pipelineTriggers([pollSCM('0 H(5-6) * * *')])
]
)
pipeline
{
agent any
options {
skipDefaultCheckout true
}
environment {
GITHUB_TOKEN = credentials('marianob85-github-jenkins')
}
stages
{
stage('Build'){
agent{ label "windows/buildtools2022" }
steps {
checkout scm
script {
env.GITHUB_REPO = sh(script: 'basename $(git remote get-url origin) .git', returnStdout: true).trim()
}
powershell './BuildScripts/InjectGitVersion.ps1 -Version $env:BUILD_NUMBER'
bat '''
call "C:/BuildTools/VC/Auxiliary/Build/vcvars64.bat"
nuget restore CodeBeautifier.sln
msbuild CodeBeautifier.sln /t:Rebuild /p:Configuration=Release;Platform="x64" /p:DeployExtension=false /flp:logfile=warnings.log;warningsonly
'''
stash includes: "warnings.log", name: "warningsFiles"
stash includes: 'Installers/*, CodeBeautifier-VSPackage/bin/x64/Release/*.vsix', name: "bin"
stash includes: 'UnitTest/bin/x64/Release/*', name: "unitTest"
}
}
stage('UnitTests'){
agent{ label "windows/buildtools2022" }
steps {
unstash "unitTest"
powershell '''
vstest.console.exe UnitTest/bin/x64/Release/UnitTest.dll /Logger:trx
'''
mstest testResultsFile:"**/*.trx", keepLongStdio: true
}
}
stage('Compile check'){
agent any
steps {
unstash "warningsFiles"
script {
def warn = scanForIssues sourceCodeEncoding: 'UTF-8', tool: msBuild(id: 'msvc', pattern: 'warnings.log')
publishIssues failedTotalAll: 1, issues: [warn], name: 'Win compilation warnings'
}
}
}
stage('Archive'){
agent any
steps {
unstash "bin"
dir("Installers"){
archiveArtifacts artifacts: '*.zip', onlyIfSuccessful: true
}
dir("CodeBeautifier-VSPackage/bin/x64/Release"){
archiveArtifacts artifacts: '*.vsix', onlyIfSuccessful: true
}
}
}
stage('Release') {
when {
buildingTag()
}
agent{ label "linux/u18.04/go:1.17.3" }
steps {
unstash 'bin'
sh '''
go install github.com/github-release/github-release@v0.10.0
github-release release --user marianob85 --repo ${GITHUB_REPO} --tag ${TAG_NAME} --name ${TAG_NAME}
for filename in CodeBeautifier-VSPackage/out/Release/*.vsix; do
[ -e "$filename" ] || continue
basefilename=$(basename "$filename")
github-release upload --user marianob85 --repo ${GITHUB_REPO} --tag ${TAG_NAME} --name ${basefilename} --file ${filename}
done
for filename in Installers/*.zip; do
[ -e "$filename" ] || continue
basefilename=$(basename "$filename")
github-release upload --user marianob85 --repo ${GITHUB_REPO} --tag ${TAG_NAME} --name ${basefilename} --file ${filename}
done
'''
}
}
}
post {
changed {
emailext body: "Please go to ${env.BUILD_URL}", to: '${DEFAULT_RECIPIENTS}', subject: "Job ${env.JOB_NAME} (${env.BUILD_NUMBER}) ${currentBuild.currentResult}".replaceAll("%2F", "/")
}
}
}