-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathJenkinsfile - Pipeline Script.groovy
72 lines (62 loc) · 2.15 KB
/
Jenkinsfile - Pipeline Script.groovy
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
pipeline {
agent any
stages {
stage("Clean") {
steps {
deleteDir()
}
}
stage("Clone") {
steps {
git branch: "main",
url: "https://github.com/henriq-toledo/jenkins-sample.git"
}
}
stage("Build") {
steps {
script {
dir ("src\\JenkinsSample") {
bat "dotnet build"
}
}
}
}
stage("Unit Test") {
steps {
script {
dir ("src\\JenkinsSample\\WebApp.UnitTest") {
bat "dotnet test"
}
}
}
}
stage("Package") {
steps {
script {
dir ("src\\JenkinsSample\\WebApp") {
bat "dotnet publish --configuration Release --runtime win81-x64 /p:EnvironmentName=Production --self-contained false --output \"${WORKSPACE}\\publish\""
}
}
}
}
stage("Deploy") {
steps {
script {
try {
echo "Stopping App Pool"
bat "%systemroot%\\system32\\inetsrv\\appcmd stop apppool /apppool.name:DefaultAppPool"
}
catch (Exception err) {
echo err.getMessage()
}
echo "Cleaning the app folder"
bat "del \"C:\\inetpub\\wwwroot\\jenkins-sample-web-app\\**\" /S /Q"
echo "Copying the published files to the app folder"
bat "xcopy \"${WORKSPACE}\\publish\\**\" \"C:/inetpub/wwwroot/jenkins-sample-web-app\" /E /Q"
echo "Starting App Pool"
bat "%systemroot%\\system32\\inetsrv\\appcmd start apppool /apppool.name:DefaultAppPool"
}
}
}
}
}