-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsFile
99 lines (96 loc) · 2.6 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
@Library('AdminAppsSharedLibrary') _
def copyOperations = [
[
source: ".\\web\\bin\\Release\\net7.0\\publish",
testDestination: "%vipertestnet%",
prodDestination: "%viperprodnet%",
includeFiles: "*.*",
excludeFiles: "",
excludeDirectories: ""
]
]
def copyOfflineOperations = [
[
source: ".",
testDestination: "%vipertestnet%",
prodDestination: "%viperprodnet%",
includeFiles: "app_offline.htm",
excludeFiles: "",
excludeDirectories: ""
]
]
pipeline {
agent any
tools { nodejs "NodeJS 20.6.1" }
options {
skipStagesAfterUnstable()
}
stages {
stage('Restore packages') {
steps {
bat '"C:\\Program Files\\dotnet\\dotnet" restore Viper.sln'
}
}
stage('Clean Previous Build') {
steps {
bat '"C:\\Program Files\\dotnet\\dotnet" clean Viper.sln'
}
}
stage('Build for test') {
when {
expression { params.Branch == 'development' }
}
steps {
bat 'pushd VueApp && npm install && popd'
bat 'npm run --prefix VueApp build-test'
bat '"C:\\Program Files\\dotnet\\dotnet" publish ./web/Viper.csproj -c "Release" /p:EnvironmentName=Test'
}
}
stage('Build for prod') {
when {
expression { params.Branch == 'master' || params.Branch == "main" }
}
steps {
bat 'pushd VueApp && npm install && popd'
bat 'npm run --prefix VueApp build'
bat '"C:\\Program Files\\dotnet\\dotnet" publish ./web/Viper.csproj -c "Release" /p:EnvironmentName=Production'
}
}
stage('Tests') {
steps {
bat 'type NUL > app_offline.htm'
bat '"C:\\Program Files\\dotnet\\dotnet" test ./test/Viper.test.csproj -e Test --logger "junit" --configuration release --nologo'
}
}
stage('Deploy to test') {
when {
expression { params.Branch == 'development' }
}
steps {
filecopy copyOfflineOperations, 'test', env.WORKSPACE
filecopy copyOperations, 'test', env.WORKSPACE
}
}
stage('Deploy to prod') {
when {
expression { params.Branch == 'master' || params.Branch == "main" }
}
steps {
filecopy copyOfflineOperations, 'prod', env.WORKSPACE
filecopy copyOperations, 'prod', env.WORKSPACE
}
}
}
post {
always {
//Run junit on the test report to build output
script {
if(fileExists('test/TestResults/TestResults.xml')) {
junit testResults: 'test/TestResults/TestResults.xml', skipPublishingChecks: true
}
}
//Archive the artifacts - in this case, all files - so that the restore job can re-deploy them.
archiveArtifacts artifacts: 'web/bin/Release/net7.0/publish/**/*', fingerprint: true, onlyIfSuccessful: true
}
}
}