-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathJenkinsfile
132 lines (114 loc) · 4 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
def targetNode = KML_ENV == "Production" ? 'geoserverprod' : 'geoservertest'
node (targetNode) {
try {
parameters {
string(name: 'SDLC', defaultValue: 'DLVR')
string(name: 'APP', defaultValue: 'fcbc')
string(name: 'APPSERVER', defaultValue: 'kurhah.dmz')
}
switch (KML_ENV) {
case "Delivery":
echo "Building dlvr"
env.SDLC = 'DLVR'
env.APPSERVER = 'kurhah.dmz'
break
case "Test":
echo "Building test"
env.SDLC = 'TEST'
env.APPSERVER = 'kurhah.dmz'
break
case "Production":
echo "Building prod"
env.SDLC = 'PROD'
env.APPSERVER = 'imai.dmz'
break
default:
println "That was unexpected with variable ENV"
}
switch (KML_APP) {
case "fcbc":
echo "Building fcbc"
env.APP = 'fcbc'
break
case "geobc":
echo "Building geobc"
env.APP = 'geobc'
break
case "geocoder":
echo "Building geocoder"
env.APP = 'geocoder'
break
case "geomark":
echo "Building geomark"
env.APP = 'geomark'
break
case "Icons":
echo "Building Icons"
env.APP = 'Icons'
break
default:
println "That was unexpected with variable APP"
}
echo "This is my echo with env.SDLC: ${env.SDLC}"
echo "This is my echo with env.APPSERVER: ${env.APPSERVER}"
echo "This is my echo with env.APP: ${env.APP}"
echo "This is my echo with KML_gitTag: ${KML_gitTag}"
echo "This is my target node: ${targetNode}"
echo "Set variables that can be used in external processes"
withEnv ([
"JOB_NAME=kml-build",
"GIT_SSL_NO_VERIFY=true",
"APPSERVER=${env.APPSERVER}",
"APP=${env.APP}",
"SDLC=${env.SDLC}"
])
{
echo "JOB_NAME: ${JOB_NAME}"
echo "GIT_SSL_NO_VERIFY: ${GIT_SSL_NO_VERIFY}"
echo "APPSERVER: ${APPSERVER}"
echo "APP: ${APP}"
echo "SDLC: ${SDLC}"
echo "KML_gitTag: ${KML_gitTag}"
stage ('SCM prepare'){
echo 'Building Stage 1 - Check out source code'
deleteDir()
checkout([$class: 'GitSCM', branches: [[name: '${KML_gitTag}']], doGenerateSubmoduleConfigurations: false, extensions: [], gitTool: 'Default', submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/bcgov/dbc-kml-apps.git']]])
}
stage ('Build using Ant and copy configs to server'){
echo 'Building using Ant and copy configs to the server'
bat '''
echo "Temp is : %TEMP%"
echo "Tmp is : %TMP%"
echo "Path is : %PATH%"
echo "Workspace is : %WORKSPACE%"
echo "Appserver is: %APPSERVER%"
echo "SDLC is: %SDLC%"
echo: "call ant -buildfile E:\\sw_nt\\jenkins\\workspace\\waops\\fcbc_kml\\deploy\\%SDLC%\\build.xml"
call E:\\sw_nt\\ant\\bin\\ant -buildfile %WORKSPACE%\\deploy\\%SDLC%\\build.xml
echo: "NOTE FOR MYSELF - all substitutions have and extra quote after the substitution. This needs to be removed"
echo Copy the kml files from: %WORKSPACE%\\kml\\%APP%\\*
echo Copy the kml files to: \\\\%APPSERVER%\\e$\\inetpub\\wwwroot\\kml\\%APP%\\*
xcopy %WORKSPACE%\\kml\\%APP%\\* \\\\%APPSERVER%\\e$\\inetpub\\wwwroot\\kml\\%APP%\\* /q /i /e /y /h
IF %ERRORLEVEL% NEQ 0 (
echo "Error: Unable to copy the kml files into place"
exit 200
)
'''
}
} // end of withEnv block
} // end of try
catch (e) {
currentBuild.result = "FAILED"
notifyFailed()
echo "Job Fails"
throw e
} // end of catch
} // end of node
def notifyFailed() {
emailext (
subject: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """<html><body><p>FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at "<a href="${env.BUILD_URL}">${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p></html></body>""",
to: '[email protected]'
)
} // end of def