Produced by Araxis Merge on 4/18/2019 5:55:29 PM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | MCCF_EDI_TAS_TASCore v2.0_Build_10.zip\MCCF_EDI_TAS_SVC_FHIR_Services | Jenkinsfile | Wed Apr 3 02:27:50 2019 UTC |
2 | MCCF_EDI_TAS_TASCore v2.0_Build_10.zip\MCCF_EDI_TAS_SVC_FHIR_Services | Jenkinsfile | Tue Apr 16 15:27:28 2019 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 1508 |
Changed | 1 | 2 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | pipeline() { | |
2 | environm ent{ | |
3 | def pr oductAcron ym="TAS" | |
4 | def pr oductMajor Version='0 1' | |
5 | def pr oductMinor Version='0 0' | |
6 | def pr oductRev=' ' | |
7 | def pa ckageVersi on="${prod uctMajorVe rsion}.${p roductMino rVersion}" | |
8 | def hc Room = '32 42078' | |
9 | def da teString = new Date( currentBui ld.startTi meInMillis ).format(' yyyyMMdd_H Hmmss') | |
10 | def LO G_DIR = "$ {WORKSPACE }/logs" | |
11 | def DI ST_OUTPUT_ FILENAME=' ' | |
12 | def DI ST_OUTPUT_ FILE='' | |
13 | def la stCommitID ='' | |
14 | def pa ckageName= '' | |
15 | def WE B_BASEDIR= "/var/www/ html" | |
16 | def ST AGING_DIR= "${WEB_BAS EDIR}/dev/ tas" | |
17 | def in dex="./src /main/weba pp/index.h tml" | |
18 | def in dexBackup= "index.htm l.bak" | |
19 | def mc cf_git_rep o="https:/ /bitbucket .org/halfa ker/mccf_v a_fhir_ser ver" | |
20 | def bu ildResultU UID='' | |
21 | def TA SWorkspace ="${WORKSP ACE}" | |
22 | def FH IR_Service s="MCCF_ED I_TAS_SVC_ FHIR_Servi ces" | |
23 | def pr oductBuild Dir="${FHI R_Services }/VA-FHIR- Server" | |
24 | def pr oductTarge tDir="${pr oductBuild Dir}/targe t" | |
25 | def TA S_BUILD_AR TIFACTS="B uild_Artif acts" | |
26 | def la stGitTag=' ' | |
27 | def sc mtool="/op t/ibm/team concert/6. 0.1/jazz/s cmtools/ec lipse/scm. sh" | |
28 | def lo calTMP="${ WORKSPACE} /tmp" | |
29 | } | |
30 | agent an y | |
31 | options { timestam ps() } | |
32 | stages{ | |
33 | stage( 'Prepare w orkspace w ith source code') { | |
34 | step s{ | |
35 | sc ript{ | |
36 | def bldENV =ENV?.trim ().toUpper Case() | |
37 | echo "dete rmine regi on for ${b ldENV}" | |
38 | def region =bldENV[0. .2] | |
39 | echo "dete rmine main env for r egion ${re gion}, (ak a ${bldENV })" | |
40 | def mainEN V=bldENV[- 3..-1] | |
41 | echo "dete rmine acti on for ${b ldENV}, (a ka ${regio n}, ${main ENV})" | |
42 | switch(reg ion){ | |
43 | case "AW S": | |
44 | echo " AWS enviro nment, Pre pare Halfa ker worksp ace" | |
45 | dir("$ {FHIR_Serv ices}"){ | |
46 | getH alfakerCod e() | |
47 | } | |
48 | break | |
49 | case "ED E": | |
50 | case "MA G": | |
51 | echo ( "Initializ e workspac e from RTC ") | |
52 | if (!T GT_STREAM? .trim().to UpperCase( ).equals(" DEV")){ | |
53 | STAG ING_DIR="$ {WEB_BASED IR}/rtc/ta s" | |
54 | } | |
55 | teamco ncert([ | |
56 | buil dType: [ | |
57 | bu ildDefinit ion: "${bu ildDefinit ionId}", | |
58 | va lue: 'buil dDefinitio n' | |
59 | ] | |
60 | ]) | |
61 | echo ( "Verify co mponent ($ {FHIR_Serv ices}) exi sts") | |
62 | sh ''' | |
63 | if [ [ -d "${FH IR_Service s}" ]] | |
64 | then | |
65 | ec ho "Compon ent (${FHI R_Services }) exists, safe to p roceed" | |
66 | else | |
67 | fa il "FAIL: No compone nt (${FHIR _Services} ) found" | |
68 | fi | |
69 | ''' | |
70 | echo " EDE enviro nment, det ermine SRC _STREAM" | |
71 | if(mai nENV.equal s("DEV") & & SRC_STR EAM?.trim( ).toUpperC ase().equa ls("HAF")) { | |
72 | echo "need to get HAF co de" | |
73 | dir( "${localTM P}"){ | |
74 | ge tHalfakerC ode() | |
75 | ec ho "need t o check la stGitCommi t against lastGitTag " | |
76 | } | |
77 | dir( "${FHIR_Se rvices}"){ | |
78 | sh 'cp -p .p roject ../ taswebui.p roject' | |
79 | sh 'rsync -a cvWh "${lo calTMP}/" . --exclud e ".git" - -del' | |
80 | sh 'mv ../ta swebui.pro ject .proj ect' | |
81 | } | |
82 | } | |
83 | break | |
84 | default: | |
85 | echo " local envi ronment, P repare Hal faker work space" | |
86 | dir("$ {FHIR_Serv ices}"){ | |
87 | getH alfakerCod e() | |
88 | } | |
89 | } | |
90 | } | |
91 | } | |
92 | } | |
93 | stage( 'Pre-Build Setup'){ | |
94 | envi ronment { | |
95 | de f pom = '' | |
96 | } | |
97 | step s{ | |
98 | ec ho ("verif y there ar e no repos itories li sted in PO M") | |
99 | di r("${produ ctBuildDir }"){ | |
100 | script{ | |
101 | pom = re adMavenPom file: 'po m.xml' | |
102 | reposito ries = pom .repositor ies | |
103 | if (repo sitories){ | |
104 | echo ( "repositor es are ${r epositorie s}") | |
105 | error( "Build fai led becaus e there ar e reposito ries prese nt") | |
106 | } | |
107 | else{ | |
108 | echo " no reposit ories list ed, procee d" | |
109 | } | |
110 | echo "po mVersion i s ${pom.ve rsion}" | |
111 | sh 'mkdi r -p ${LOG _DIR}' | |
112 | echo "se t final pa ckageVersi on" | |
113 | packageV ersion="${ pom.versio n}" | |
114 | if(ENV?. trim().toU pperCase() .startsWit h("EDE") | | ENV?.tri m().toUppe rCase().st artsWith(" MAG")){ | |
115 | echo " building i n EDE, do not use gi t commit i n packageV ersion" | |
116 | produc tRev="${BU ILD_NUMBER }_${dateSt ring}" | |
117 | } | |
118 | else { | |
119 | echo " git build" | |
120 | lastCo mmitID=get LastGitCom mit() | |
121 | echo " last commi t is ${las tCommitID} " | |
122 | if(las tCommitID? .trim()){ | |
123 | pr oductRev=" ${BUILD_NU MBER}_${la stCommitID }" | |
124 | } | |
125 | } | |
126 | echo "fi nal packag eVersion f or tag ${p ackageVers ion}.${pro ductRev}" | |
127 | packageN ame="${pom .artifactI d}" | |
128 | packageE xt="${pom. packaging. toLowerCas e()}" | |
129 | DIST_OUT PUT_FILENA ME="${pack ageName}_$ {packageVe rsion}.${p roductRev} .${package Ext}" | |
130 | echo "bu ilding for package $ {DIST_OUTP UT_FILENAM E}" | |
131 | echo "up dating met adata for ${index}" | |
132 | updateIn dexMetaDat a() | |
133 | } | |
134 | } | |
135 | } | |
136 | } | |
137 | stage( 'Build'){ | |
138 | step s{ | |
139 | ec ho "build the projec t ${FHIR_S ervices}" | |
140 | di r ("${prod uctBuildDi r}"){ | |
141 | //sh """mv n -X -l ${ LOG_DIR}/c ompile_${d ateString} .log clean compile"" " | |
142 | sh """mvn -X clean com pile""" | |
143 | } | |
144 | } | |
145 | } | |
146 | stage( 'Test-unit '){ | |
147 | step s{ | |
148 | di r ("${prod uctBuildDi r}"){ | |
149 | sh """mvn -e -Dmaven .test.fail ure.ignore =false -Dg roups="Uni t" test""" | |
150 | } | |
151 | } | |
152 | } | |
153 | stage( 'Prepare P ackage') { | |
154 | step s{ | |
155 | ec ho ("Prepa re to pack age ${DIST _OUTPUT_FI LENAME}") | |
156 | di r ("${prod uctBuildDi r}"){ | |
157 | echo "prep are to bui ld package for -Dbui ld.number= \".${produ ctRev}\" " | |
158 | sh """mvn -X -DskipT ests -Dbui ld.number= "${product Rev}" clea n package" "" | |
159 | echo ("Ver ify packag e ${DIST_O UTPUT_FILE NAME} for distributi on") | |
160 | } | |
161 | sc ript{ | |
162 | if (fileEx ists("${pr oductTarge tDir}/${DI ST_OUTPUT_ FILENAME}" )) { | |
163 | echo "${ DIST_OUTPU T_FILENAME } created, prepare t o archive" | |
164 | DIST_OUT PUT_FILE=" ${productT argetDir}/ ${DIST_OUT PUT_FILENA ME}" | |
165 | echo "ar chiving as DIST_OUTP UT_FILE ${ DIST_OUTPU T_FILE}" | |
166 | } | |
167 | else { | |
168 | error("F AIL: ${DIS T_OUTPUT_F ILENAME} n ot created ") | |
169 | } | |
170 | } | |
171 | } | |
172 | } | |
173 | stage( 'Stage Pac kage') { | |
174 | step s{ | |
175 | ec ho "stage the packag ed distrib ution (${D IST_OUTPUT _FILE}) fo r ${packag eName}" | |
176 | st ageLatestA rtifact("$ {DIST_OUTP UT_FILE}") | |
177 | } | |
178 | } | |
179 | } | |
180 | post{ | |
181 | always { | |
182 | echo "POST alw ays: all t asks are c ompleted, collecting environme nt variabl es to ${WO RKSPACE}/$ {BUILD_TAG }.log" | |
183 | sh ' printenv > > $WORKSPA CE/$BUILD_ TAG.log' | |
184 | echo "POST alw ays: archi ving all l ogs and ar tifacts sp ecified" | |
185 | juni t allowEmp tyResults: true, hea lthScaleFa ctor: 1.0, testResul ts: '**/ta rget/suref ire-report s/**/*.xml ' | |
186 | } | |
187 | succes s{ | |
188 | echo 'POST suc cess: chec k environm ent to det ermine com mit action s' | |
189 | scri pt { | |
190 | de f myENV="$ {ENV}" | |
191 | de f subENV=m yENV[0..2] | |
192 | de f EDE_ARTI FACT_LOCAT ION = "${W ORKSPACE}/ ${TAS_BUIL D_ARTIFACT S}/${packa geVersion} " | |
193 | ec ho "POST s uccess: de termine pr oper commi t action f or ${myENV }, (aka ${ subENV})" | |
194 | sw itch(subEN V.toUpperC ase()){ | |
195 | case "AWS" : | |
196 | echo "PO ST success : AWS envi ronment, u se git to tag this b uild" | |
197 | gitTagBu ild() | |
198 | echo "PO ST success : in AWS, make hipch at notific ation" | |
199 | notifyHi pchat(curr entBuild.r esult,hcRo om) | |
200 | break | |
201 | case "EDE" : | |
202 | case "MAG" : | |
203 | echo "PO ST success : copy pac kaged arti fact (${DI ST_OUTPUT_ FILE}) to ${TAS_BUIL D_ARTIFACT S}" | |
204 | sh """ | |
205 | mkdir -p "${EDE_ ARTIFACT_L OCATION}" | |
206 | cp "${ DIST_OUTPU T_FILE}" " ${EDE_ARTI FACT_LOCAT ION}/" | |
207 | echo " POST succe ss: check ${EDE_ARTI FACT_LOCAT ION}/${DIS T_OUTPUT_F ILENAME}" | |
208 | if [[ -f "${EDE_ ARTIFACT_L OCATION}/$ {DIST_OUTP UT_FILENAM E}" ]] | |
209 | then | |
210 | echo "POST suc cess: Arti fact (${ED E_ARTIFACT _LOCATION} /${DIST_OU TPUT_FILEN AME}) exis ts, safe t o proceed" | |
211 | else | |
212 | fail "FAIL: PO ST success : No artif act (${EDE _ARTIFACT_ LOCATION}/ ${DIST_OUT PUT_FILENA ME}) found " | |
213 | fi | |
214 | """ | |
215 | echo "cl eanup prio r to check in and del iver" | |
216 | dir("${p roductBuil dDir}"){ | |
217 | sh "mv ${indexBa ckup} ${in dex}" | |
218 | sh 'rm -rf **/lo gs' | |
219 | sh 'rm -rf targe t' | |
220 | sh 'fi nd . -name "*.log" - type f -de lete' | |
221 | } | |
222 | dir("${F HIR_Servic es}"){ | |
223 | sh 'rm -rf **/lo gs' | |
224 | sh 'fi nd . -name "*.log" - type f -de lete' | |
225 | sh 'rm -rf *@*' | |
226 | } | |
227 | rtcCheck in() | |
228 | rtcDeliv er() | |
229 | echo "PO ST success : send ema il notific ation" | |
230 | notifyBu ildStatus( currentBui ld.result) | |
231 | break | |
232 | default: | |
233 | echo "POS T success: local env ironment, send no no tices" | |
234 | echo "POS T success: local env ironment, do not com mit any ta g" | |
235 | } | |
236 | } | |
237 | echo "POST suc cess: coll ecting con sole log" | |
238 | getC onsoleLog( ) | |
239 | arch iveArtifac ts allowEm ptyArchive : true, ar tifacts: ' **/*.log, **/target/ *.war, *.p om, **/tar get/surefi re-reports /**/*.xml' , onlyIfS uccessful: false | |
240 | echo 'POST suc cess: Perf orming cle anup tasks after bui ld success ' | |
241 | dele teDir() | |
242 | } | |
243 | failur e{ | |
244 | scri pt{ | |
245 | if (BUILD_URL .toLowerCa se().conta ins("aws") ){ | |
246 | echo "POST failure: in AWS, ma ke hipchat notificat ion" | |
247 | notifyHipc hat(curren tBuild.res ult,hcRoom ) | |
248 | } | |
249 | if (ENV.toLow erCase().c ontains("l ocal")){ | |
250 | echo "PO ST failure : local en vironment, send no n otices" | |
251 | } | |
252 | el se{ | |
253 | echo "POST failure: send email notificat ion" | |
254 | notifyBuil dStatus(cu rrentBuild .result) | |
255 | } | |
256 | } | |
257 | echo "POST fai lure: coll ecting con sole log" | |
258 | getC onsoleLog( ) | |
259 | arch iveArtifac ts allowEm ptyArchive : true, ar tifacts: ' **/*.log, **/target/ surefire-r eports/**/ *.xml' , o nlyIfSucce ssful: fal se | |
260 | echo 'POST fai lure: Perf orming cle anup tasks for build failure' | |
261 | dele teDir() | |
262 | } | |
263 | } | |
264 | } | |
265 | // RTC ste ps for che ckin and d eliver | |
266 | def rtcChe ckin(){ | |
267 | withCred entials([u sernamePas sword(cred entialsId: 'RTC_BUIL D', userna meVariable : 'rtcUser ', passwor dVariable: 'rtcPass' )]) { | |
268 | // avail able as an env varia ble, but w ill be mas ked if you try to pr int it out any which way | |
269 | def MY HOSTNAME=g etHostname () | |
270 | def la stBuildDat e=new Date (currentBu ild.startT imeInMilli s).format( 'MMM dd, y yyy HH:mm: ss Z') | |
271 | def ve rsionStrin g="version : ${packag eVersion}" | |
272 | def bu ildDateStr ing="lastB uildDate: ${lastBuil dDate}" | |
273 | def di stribution String="di stribution FileName: <staging_u rl>/${DIST _OUTPUT_FI LENAME}" | |
274 | def co mmitCommen t = /"jenk ins-${JOB_ BASE_NAME} -${BUILD_N UMBER}-${M YHOSTNAME} ,${version String}, $ {buildDate String}, $ {distribut ionString} "/ | |
275 | def wo rkitem = " ${RTC_WORK ITEM}" | |
276 | def co mponents= ["${FHIR_S ervices}"] | |
277 | ||
278 | echo " show scm s tatus" | |
279 | sh """ | |
280 | ${sc mtool} sho w status - u ${rtcUse r} -P ${rt cPass} -v --all -d $ {TASWorksp ace} | |
281 | echo "----- -- --- ----- ----- ---- -" | |
282 | """ | |
283 | ||
284 | echo " prepare to checkin c omponents" | |
285 | for (c omponent i n componen ts){ | |
286 | echo "loop thr ough each file in $c omponent" | |
287 | sh " "" | |
288 | fi nd $compon ent -maxde pth 1 -typ e f -name '.*' -exec ${scmtool } checkin -u ${rtcUs er} -P ${r tcPass} -- comment ${ commitComm ent} --wor kitem ${wo rkitem} -v -d ${TASW orkspace} ${TASWorks pace}/{} \ \; | |
289 | """ | |
290 | echo "${scmtoo l} checkin $componen t/*" | |
291 | sh " ${scmtool} checkin - u ${rtcUse r} -P ${rt cPass} --c omment ${c ommitComme nt} --work item ${wor kitem} -v -d ${TASWo rkspace} $ {TASWorksp ace}/$comp onent/*" | |
292 | echo "----- -- --- ----- ----- ---- -" | |
293 | } | |
294 | // the following is not va lid until rtc 6.0.4 | |
295 | //step ([$class: 'RTCPostBu ildDeliver Publisher' , failOnEr ror: true] ) | |
296 | } | |
297 | } | |
298 | ||
299 | def rtcDel iver(){ | |
300 | withCred entials([u sernamePas sword(cred entialsId: 'RTC_BUIL D', userna meVariable : 'rtcUser ', passwor dVariable: 'rtcPass' )]) { | |
301 | // avail able as an env varia ble, but w ill be mas ked if you try to pr int it out any which way | |
302 | def wo rkitem = " ${RTC_WORK ITEM}" | |
303 | echo " show scm s tatus" | |
304 | sh """ | |
305 | ${sc mtool} sho w status - u ${rtcUse r} -P ${rt cPass} -v --all -d $ {TASWorksp ace} | |
306 | echo "----- -- --- ----- ----- ---- -" | |
307 | """ | |
308 | echo " RTC ${rtcU ser} deliv er " | |
309 | def de liverStatu s=sh ( | |
310 | script : "${scmto ol} delive r -u ${rtc User} -P $ {rtcPass} -v", | |
311 | return Status: tr ue | |
312 | ) | |
313 | if (de liverStatu s == 0 || deliverSta tus == 52 || deliver Status == 53){ | |
314 | echo "Deliver succeeded" | |
315 | retu rn 0 | |
316 | } | |
317 | el se if (del iverStatus == 11) { | |
318 | echo "Acce pt incomin g changes" | |
319 | def accept Status=sh ( | |
320 | script: "$ {scmtool} accept -u ${rtcUser} -P ${rtcP ass} -v", | |
321 | returnStat us: true | |
322 | ) | |
323 | if (accept Status == 0) { | |
324 | def redo DeliverSta tus=sh ( | |
325 | scri pt: "${scm tool} deli ver -u ${r tcUser} -P ${rtcPass } -v", | |
326 | retu rnStatus: true | |
327 | ) | |
328 | if ( redodelive rStatus == 0 || deli verStatus == 52 || d eliverStat us == 53){ | |
329 | ec ho "Accept and Deliv er succeed ed" | |
330 | re turn 0 | |
331 | } | |
332 | } | |
333 | } | |
334 | else { | |
335 | currentBui ld.result= 'FAILED' | |
336 | erro r("FAIL: S CM deliver failed wi th ${deliv erStatus}" ) | |
337 | } | |
338 | // the following is not va lid until rtc 6.0.4 | |
339 | //step ([$class: 'RTCPostBu ildDeliver Publisher' , failOnEr ror: true] ) | |
340 | } | |
341 | } | |
342 | ||
343 | def rtcBas eline(){ | |
344 | withCred entials([u sernamePas sword(cred entialsId: 'RTC_BUIL D', userna meVariable : 'rtcUser ', passwor dVariable: 'rtcPass' )]) { | |
345 | // avail able as an env varia ble, but w ill be mas ked if you try to pr int it out any which way | |
346 | echo " RTC list w orkspaces " | |
347 | def wo rkspaceLis t=sh ( | |
348 | script : "${scmto ol} list w orkspaces -r local - v", | |
349 | return Stdout: tr ue | |
350 | ).trim () | |
351 | ||
352 | echo " workspace: ${workspa ceList}" | |
353 | ||
354 | echo " RTC ${rtcU ser} creat e baseline " | |
355 | sh """ | |
356 | ${sc mtool} del iver -u ${ rtcUser} - P ${rtcPas s} -v | |
357 | """ | |
358 | // the following is not va lid until rtc 6.0.4 | |
359 | //step ([$class: 'RTCPostBu ildDeliver Publisher' , failOnEr ror: true] ) | |
360 | } | |
361 | } | |
362 | ||
363 | // load wo rkspace | |
364 | def getHal fakerCode( ){ | |
365 | echo "ge t the code " | |
366 | sh """ | |
367 | git co nfig --glo bal core.a utocrlf fa lse | |
368 | """ | |
369 | git cred entialsId: 'jenkins_ build', ur l: "${mccf _git_repo} ", poll: f alse | |
370 | echo ("g et last gi t tag") | |
371 | lastGitT ag=gitDesc ribe() | |
372 | def last Commit=get LastGitCom mit() | |
373 | echo ("c heck lastG itTag (${l astGitTag} )") | |
374 | echo ("n eed to ver ify last c ommit (${l astCommit} ) is part of last ta g (${lastG itTag}), s o we can c heckin") | |
375 | if ( las tGitTag?.t rim() ){ | |
376 | echo ( "Ready to build ${la stGitTag} (${lastCom mit})") | |
377 | } | |
378 | else { | |
379 | error( "FAIL: no source pul led from $ {mccf_git_ repo}") | |
380 | } | |
381 | } | |
382 | ||
383 | // git fu nctions | |
384 | def getCha ngesets(){ | |
385 | def ch angeLogSet s = curren tBuild.cha ngeSets | |
386 | echo " reviewing changesets :" | |
387 | def co mmitMessag e="" | |
388 | for (i nt i = 0; i < change LogSets.si ze(); i++) { | |
389 | de f entries = changeLo gSets[i].i tems | |
390 | fo r (int j = 0; j < en tries.leng th; j++) { | |
391 | def entr y = entrie s[j] | |
392 | commitMe ssage="${c ommitMessa ge} \n ${e ntry.commi tId} by ${ entry.auth or} on ${n ew Date(en try.timest amp)}" | |
393 | echo "${ entry.comm itId} by $ {entry.aut hor} on ${ new Date(e ntry.times tamp)}: ${ entry.msg} " | |
394 | def file s = new Ar rayList(en try.affect edFiles) | |
395 | for (int k = 0; k < files.si ze(); k++) { | |
396 | def file = fil es[k] | |
397 | echo " ${file .editType. name} ${fi le.path}" | |
398 | } | |
399 | } | |
400 | } | |
401 | return "${commit Message}" | |
402 | } | |
403 | ||
404 | def gitDes cribe(){ | |
405 | echo "ge tting last git tag" | |
406 | def MYIN FO | |
407 | def tagE xists=sh(r eturnStdou t: true, s cript: 'gi t tag --li st').trim( ) | |
408 | if ( tag Exists?.tr im() ) { | |
409 | MYINFO =sh(return Stdout: tr ue, script : 'git des cribe').tr im() | |
410 | } | |
411 | else { | |
412 | MYINFO =sh(return Stdout: tr ue, script : 'git des cribe --al ways').tri m() | |
413 | } | |
414 | echo ("w e need to parse ${MY INFO} to d etermine i f the late st tag is the latest commit") | |
415 | MYINFO | |
416 | } | |
417 | ||
418 | def getLas tGitCommit (){ | |
419 | echo "ge tting last git commi t" | |
420 | def LAST _COMMIT | |
421 | LAST_COM MIT = sh ( | |
422 | script : 'git rev -parse HEA D', | |
423 | return Stdout: tr ue | |
424 | ).trim() | |
425 | echo ("t he last co mmit is ${ LAST_COMMI T[0..6]}") | |
426 | LAST_COM MIT[0..6] | |
427 | } | |
428 | ||
429 | def gitTag Build(){ | |
430 | withCred entials([u sernamePas sword(cred entialsId: 'jenkins_ build', pa sswordVari able: 'jen kinsPass', usernameV ariable: ' jenkinsUse r')]) { | |
431 | def MY HOSTNAME=g etHostname () | |
432 | def co mmit_messa ge = /"jen kins-${JOB _BASE_NAME }-${BUILD_ NUMBER}-${ MYHOSTNAME }"/ | |
433 | echo " set the us er.name" | |
434 | sh 'gi t config u ser.name " ${jenkinsU ser}"' | |
435 | echo " set the us er.email" | |
436 | def uE mail = /"m ccfsystema dmins@half aker.com"/ | |
437 | sh """ | |
438 | git config --g lobal push .default s imple | |
439 | git config use r.email ${ uEmail} | |
440 | git config ali as.version log "notes --ref=ver sionlog ap pend" | |
441 | git config --a dd remote. origin.pus h '+refs/n otes/*:ref s/notes/*' | |
442 | git config --a dd remote. origin.fet ch '+refs/ notes/*:re fs/notes/* ' | |
443 | git config --l ist | |
444 | """ | |
445 | echo " append ver sion note to this co mmit" | |
446 | addGit VersionLog () | |
447 | echo " tag this c ommit" | |
448 | sh """ | |
449 | git tag -a ${p ackageVers ion}${prod uctRev} -m '${commit _message}' ${lastCom mitID} | |
450 | echo "push cha nges to re mote" | |
451 | git push origi n --tags - -verbose | |
452 | """ | |
453 | } | |
454 | } | |
455 | ||
456 | def addGit VersionLog (){ | |
457 | def last BuildDate= new Date(c urrentBuil d.startTim eInMillis) .format('M MM dd, yyy y HH:mm:ss Z') | |
458 | def vers ionString= "version: ${packageV ersion}${p roductRev} " | |
459 | def buil dDateStrin g="lastBui ldDate: ${ lastBuildD ate}" | |
460 | def dist ributionSt ring="dist ributionFi leName: <s taging_url >/${DIST_O UTPUT_FILE NAME}" | |
461 | sh """ | |
462 | git ve rsionlog $ {lastCommi tID} -m "$ {versionSt ring}, ${b uildDateSt ring}, ${d istributio nString}" | |
463 | """ | |
464 | } | |
465 | ||
466 | // helper functions | |
467 | def getHos tname(){ | |
468 | def THIS HOSTNAME | |
469 | if(isUni x()){ | |
470 | THISHO STNAME = s h ( | |
471 | scri pt: 'hostn ame', | |
472 | retu rnStdout: true | |
473 | ).trim () | |
474 | } | |
475 | else { | |
476 | THISHO STNAME = b at ( | |
477 | scri pt: 'hostn ame', | |
478 | retu rnStdout: true | |
479 | ).trim () | |
480 | } | |
481 | THISHOST NAME | |
482 | } | |
483 | ||
484 | def getPac kageName() { | |
485 | echo "ge tting pack age name" | |
486 | def MYNA ME | |
487 | MYNAME = sh ( | |
488 | scri pt: 'npm r un env | g rep npm_pa ckage_name | cut -d \"=\" -f 2 ', | |
489 | retu rnStdout: true | |
490 | ).trim () | |
491 | MYNAME | |
492 | } | |
493 | ||
494 | def update IndexMetaD ata(){ | |
495 | def last BuildDate= new Date(c urrentBuil d.startTim eInMillis) .format('M MM dd, yyy y HH:mm:ss Z') | |
496 | def meta Data=["dis tributionF ileName":" ${DIST_OUT PUT_FILENA ME}", "las tBuildDate ":"${lastB uildDate}" , "version ":"${packa geVersion} ${productR ev}" ] | |
497 | echo 'ba ckup the i ndex file bfore edit ing' | |
498 | sh "cp $ {index} ${ indexBacku p}" | |
499 | for (kv in mapToLi st(metaDat a)){ | |
500 | def n ame=kv[0] | |
501 | def c ontent=kv[ 1] | |
502 | echo "update me ta tag nam e=\"${name }\", conte nt=\"${con tent}\"" | |
503 | sh "" " | |
504 | sed -i '/<hea d>/a <meta name=\"${ name}\" co ntent=\"${ content}\" >' "${ind ex}" | |
505 | """ | |
506 | } | |
507 | } | |
508 | ||
509 | def checkD ependencie sLog(log){ | |
510 | echo "ch ecking lo g for 'not installed '" | |
511 | def MYRE SULT | |
512 | MYRESULT = sh ( | |
513 | scri pt: """ | |
514 | if grep -Exq ".*not in stalled.*" ${log} | |
515 | th en | |
516 | echo "FAIL ED: packag es not ins talled" | |
517 | el se | |
518 | echo "PROC EED: All p ackages in stalled" | |
519 | fi | |
520 | "" ", | |
521 | retu rnStdout: true | |
522 | ).trim () | |
523 | return M YRESULT | |
524 | } | |
525 | ||
526 | def stageL atestArtif act(artifa ct){ | |
527 | echo " stage the latest bui ld artifac t(${artifa ct}) for d eployment" | |
528 | def ar tifact_nam e= artifac t.tokenize ('/').last () | |
529 | def st aging = ST AGING_DIR. trim().toL owerCase() | |
530 | def la test = "${ WEB_BASEDI R}/latest_ fhir_dev" | |
531 | echo " check for TGT_STREAM " | |
532 | if(env .TGT_STREA M && env.T GT_STREAM? .trim()){ | |
533 | ec ho "TGT_ST REAM found (${TGT_ST REAM})" | |
534 | de f link=TGT _STREAM.tr im().toLow erCase() | |
535 | la test = "${ WEB_BASEDI R}/latest_ fhir_${lin k}" | |
536 | } | |
537 | try { | |
538 | ec ho "check ${staging} directory exist" | |
539 | sh "[[ -d ${ staging} ] ] || sudo mkdir -p $ {staging}" | |
540 | ec ho "copy $ {artifact} to ${stag ing}/" | |
541 | sh "sudo cp ${artifact } ${stagin g}/" | |
542 | ec ho "create symbolic link to st aged artif act" | |
543 | sh "sudo ln -sfn ${sta ging}/${ar tifact_nam e} ${lates t}" | |
544 | ec ho "verify link crea ted" | |
545 | de f linkExis ts=sh ( | |
546 | script: "readlink ${latest}" , | |
547 | returnSt dout: true | |
548 | ).trim() | |
549 | sh """ | |
550 | if [[ -n "${linkEx ists}" ]]; then | |
551 | echo "link exi sts for ${ latest}" | |
552 | else | |
553 | echo "link not found ${l atest}" | |
554 | fi | |
555 | "" " | |
556 | } catc h(Exceptio n e){ | |
557 | ec ho "someth ing bad ha ppened whi le staging artifact, throw and fail" | |
558 | ec ho e.toStr ing() | |
559 | th row e | |
560 | } | |
561 | } | |
562 | // notifyH ipchat | |
563 | // will se nd color c oded notif ications t o hipchat | |
564 | // | |
565 | def notify Hipchat(St ring build Status = ' STARTED', String hcR oom = '324 2078') { | |
566 | // build s tatus of n ull means successful | |
567 | buildSta tus = bui ldStatus ? : 'SUCCESS FUL' | |
568 | ||
569 | def last Build = cu rrentBuild .getPrevio usBuild() | |
570 | ||
571 | // Defau lt values | |
572 | def colo r = 'RED' | |
573 | def colo rCode = '# FF0000' | |
574 | def subj ect = "${b uildStatus }: Job '${ env.JOB_NA ME} [${env .BUILD_NUM BER}]'" | |
575 | def summ ary = "${s ubject} ($ {env.BUILD _URL})" | |
576 | ||
577 | // Ove rride defa ult values based on build stat us | |
578 | if (buil dStatus == 'STARTED' ) { | |
579 | color = 'YELLOW' | |
580 | colorC ode = '#FF FF00' | |
581 | } | |
582 | else if (buildStat us == 'SUC CESSFUL') { | |
583 | color = 'GREEN' | |
584 | colorC ode = '#00 FF00' | |
585 | if( la stBuild && lastBuild .getResult ().toStrin g()=="FAIL URE" ){ | |
586 | buil dStatus = 'FIXED' | |
587 | } | |
588 | } | |
589 | else if (buildStat us == 'ABO RTED') { | |
590 | color = 'PURPLE' | |
591 | colorC ode = '#80 0080' | |
592 | } | |
593 | else if (buildStat us == 'UNS TABLE') { | |
594 | color = 'GRAY' | |
595 | colorC ode = '#80 8080' | |
596 | } | |
597 | else { | |
598 | color = 'RED' | |
599 | colorC ode = '#FF 0000' | |
600 | } | |
601 | ||
602 | // Send notificat ions | |
603 | echo "se nd notice of ${build Status} to hipchat r oom: ${hcR oom}" | |
604 | def hcMe ssage=getC hangesets( ) | |
605 | if(build Status == 'SUCCESSFU L'){ | |
606 | echo " only send notice if previous b uild faile d" | |
607 | if( la stBuild && lastBuild .getResult ().toStrin g()=="FAIL URE" ){ | |
608 | echo "the prev ious build ${lastBui ld.getId() } failed, send updat e" | |
609 | hipc hatSend ( | |
610 | co lor: color , | |
611 | cr edentialId : 'jenkins _hc_notifi cation', | |
612 | me ssage: sum mary + ": changesets : " + hcM essage, | |
613 | no tify: true , | |
614 | ro om: hcRoom , | |
615 | se ndAs: 'jen kins_build ', | |
616 | te xtFormat: false, | |
617 | v2 enabled: t rue | |
618 | ) | |
619 | } | |
620 | else { | |
621 | echo "the prev ious build " + lastB uild.getRe sult().toS tring() | |
622 | } | |
623 | } | |
624 | else { | |
625 | echo " this build ${buildSt atus}" | |
626 | hipcha tSend ( | |
627 | colo r: color, | |
628 | cred entialId: 'jenkins_h c_notifica tion', | |
629 | mess age: summa ry + ": ch angesets: " + hcMes sage, | |
630 | noti fy: true, | |
631 | room : hcRoom, | |
632 | send As: 'jenki ns_build', | |
633 | text Format: fa lse, | |
634 | v2en abled: tru e | |
635 | ) | |
636 | } | |
637 | } | |
638 | ||
639 | def notify BuildStatu s(String b uildStatus = 'STARTE D') { | |
640 | // build status of null mean s successf ul | |
641 | buildSta tus = bui ldStatus ? : 'SUCCESS FUL' | |
642 | ||
643 | //recipien tProviders (optional ) | |
644 | //$class: CulpritsRe cipientPro vider | |
645 | //Sends em ail to the list of u sers who c ommitted a change si nce the la st non-bro ken build till now. | |
646 | //This lis t at least always in clude peop le who mad e changes in this bu ild, but i f the prev ious build | |
647 | //was a fa ilure it a lso includ es the cul prit list from there . | |
648 | ||
649 | //$class: Developers RecipientP rovider | |
650 | //Sends em ail to all the peopl e who caus ed a chang e in the c hange set. | |
651 | ||
652 | //$class: FailingTes tSuspectsR ecipientPr ovider | |
653 | //Sends em ail to the list of u sers suspe cted of ca using a un it test to begin fai ling. | |
654 | //This lis t includes committer s and requ estors of the build where the test began to fail, | |
655 | //and thos e for any consecutiv e failed b uilds prio r to the b uild in wh ich the te st began t o fail. | |
656 | ||
657 | //$class: FirstFaili ngBuildSus pectsRecip ientProvid er | |
658 | //Sends em ail to the list of u sers suspe cted of ca using the build to b egin faili ng. | |
659 | ||
660 | //$class: ListRecipi entProvide r | |
661 | //Sends em ail to the list of r ecipients defined in the "Proj ect Recipi ent List." | |
662 | ||
663 | //$class: RequesterR ecipientPr ovider | |
664 | //Sends em ail to the user who initiated the build. | |
665 | ||
666 | //$class: UpstreamCo mitterReci pientProvi der | |
667 | //Sends em ail to the list of u sers who c ommitted c hanges in upstream b uilds that triggered this buil d | |
668 | // Default values Li stRecipien tProvider | |
669 | def reci pients=[[$ class: 'Li stRecipien tProvider' ]] | |
670 | def subj ect = "${b uildStatus }: Job '${ env.JOB_NA ME} [${env .BUILD_NUM BER}]'" | |
671 | def repl yto = "${e nv.DEFAULT _REPLYTO}" | |
672 | def mime Type = "te xt/html" | |
673 | def send to = "${en v.DEFAULT_ RECIPIENTS }" | |
674 | def deta ils = """ | |
675 | <p>Job : '${env.J OB_NAME} b uild: [${e nv.BUILD_N UMBER}]':< /p> | |
676 | <p>Che ck console output at "<a href= "${env.BUI LD_URL}">$ {env.JOB_N AME} [${en v.BUILD_NU MBER}]</a> "</p> | |
677 | """ | |
678 | ||
679 | // Ove rride defa ult values based on build stat us | |
680 | if (buil dStatus == 'STARTED' || buildS tatus == ' SUCCESSFUL ' || build Status == 'FIXED') { | |
681 | recipi ents = [[$ class: 'De velopersRe cipientPro vider']] | |
682 | } | |
683 | ||
684 | else if (buildStat us == 'ABO RTED' || b uildStatus == 'UNSTA BLE') { | |
685 | recipi ents = [[$ class: 'De velopersRe cipientPro vider']] | |
686 | } | |
687 | else { | |
688 | echo " unknown st atus" | |
689 | recipi ents = [[$ class: 'Cu lpritsReci pientProvi der'], [$c lass: 'Req uesterReci pientProvi der']] | |
690 | } | |
691 | //examples | |
692 | //Notify C ulprits an d Requeste r via defa ult EMail plugin | |
693 | //step([$c lass: 'Mai ler', noti fyEveryUns tableBuild : true, re cipients: emailextre cipients([ [$class: ' CulpritsRe cipientPro vider'], [ $class: 'R equesterRe cipientPro vider']])] ) | |
694 | ||
695 | //Send an email to a bc plus an y addresse s returned by the pr oviders | |
696 | //emailext body: 'A Test EMail ', | |
697 | // recipient Providers: [[$class: 'Develope rsRecipien tProvider' ], [$class : 'Request erRecipien tProvider' ]], | |
698 | // subject: 'Test', | |
699 | // to: 'abc' | |
700 | echo "se nd email t o recipien ts (${reci pients}) f or ${build Status}" | |
701 | echo """ | |
702 | subj ect: ${sub ject}, | |
703 | body : ${detail s}, | |
704 | reci pientProvi ders: ${re cipients}, | |
705 | repl yTo: ${rep lyto}, | |
706 | to: ${sendto} | |
707 | """ | |
708 | mail ( | |
709 | body : details, | |
710 | cc: ' PII ', | |
711 | mime Type: 'tex t/html', | |
712 | repl yTo: reply to, | |
713 | subj ect: subje ct, | |
714 | to: sendto | |
715 | ) | |
716 | } | |
717 | ||
718 | //save log to worksp ace | |
719 | def getCon soleLog(){ | |
720 | //JENKI NS_HOME=/v ar/lib/jen kins | |
721 | //JENK INS_URL=ht tp://aws-m aster.mccf .halfakerl abs.com:80 80/ | |
722 | //BUIL D_URL=http ://aws-mas ter.mccf.h alfakerlab s.com:8080 /job/MCCF_ TAS/job/MC CF_TAS_Cor e/512/ | |
723 | //JOB_ URL=http:/ /aws-maste r.mccf.hal fakerlabs. com:8080/j ob/MCCF_TA S/job/MCCF _TAS_Core/ | |
724 | //log location i s /var/lib /jenkins/j obs/MCCF_T AS/jobs/MC CF_TAS_Cor e/builds/5 12 | |
725 | echo "ge tConsoleLo g: prepare logfilena me to get console lo g" | |
726 | def logF ilename="$ {JOB_URL}" | |
727 | def work spaceLog=" ${WORKSPAC E}/${JOB_B ASE_NAME}_ ${BUILD_NU MBER}_cons ole.log" | |
728 | echo "ge tConsoleLo g: console log is ${ logFilenam e} (same a s job url) " | |
729 | logFilen ame=logFil ename.trim ().replace ("${JENKIN S_URL}","$ {JENKINS_H OME}/") | |
730 | echo "ge tConsoleLo g: console log is ch anged to $ {logFilena me}" | |
731 | logFilen ame=logFil ename.trim ().replace All("job", "jobs") | |
732 | echo "ge tConsoleLo g: console log is ch anged agai n to ${log Filename}" | |
733 | logFilen ame="${log Filename}b uilds/${BU ILD_NUMBER }/log" | |
734 | echo "ge tConsoleLo g: console log is fi nally ${l ogFilename }" | |
735 | echo "ge tConsoleLo g: prepare to write to ${works paceLog}" | |
736 | sh """ | |
737 | sed -e "s,\\x1b\ \[[0-9]*.* \\x1b\\[0m ,,g;s,\\ba ctive\\b,a ctive\\n\\ r,gm;s,\\x 08,.,gm" " ${logFilen ame}" > "t mp.log" | |
738 | sed -e "s,\\x1b\ \[3[0-9][m GKA],,gm;s ,\\x1b\\[1 A,,gm;s,\\ x1b\\[2K,, gm;" "tmp. log" > "${ workspaceL og}" | |
739 | rm "tm p.log" | |
740 | echo " getConsole Log: verif y ${worksp aceLog} re ady for ar chival" | |
741 | if [[ -f "${work spaceLog}" ]] | |
742 | then | |
743 | echo "getConso leLog: loc al console log (${wo rkspaceLog }) exists, safe to p roceed" | |
744 | else | |
745 | echo "getConso leLog: No local cons ole log ($ {workspace Log}) foun d" | |
746 | fi | |
747 | """ | |
748 | } | |
749 | // Require d due to J ENKINS-274 21 | |
750 | @NonCPS | |
751 | List<List< ?>> mapToL ist(Map ma p) { | |
752 | return m ap.collect { it -> | |
753 | [it.ke y, it.valu e] | |
754 | } | |
755 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.