1228. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 3/13/2018 7:48:00 PM Central 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.

1228.1 Files compared

# Location File Last Modified
1 TASCore_v1.0_Build_2_Jan_2018.zip\MCCF_EDI_TAS_WebUI Jenkinsfile Thu Feb 15 20:35:26 2018 UTC
2 TASCore_v1.0_Build_2_Jan_2018.zip\MCCF_EDI_TAS_WebUI Jenkinsfile Fri Mar 9 17:09:07 2018 UTC

1228.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 4 1670
Changed 3 6
Inserted 0 0
Removed 0 0

1228.3 Comparison options

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

1228.4 Active regular expressions

No regular expressions were active.

1228.5 Comparison detail

  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=" ${BUILD_NU MBER}"
  7       def pa ckageVersi on="${prod uctAcronym }.${produc tMajorVers ion}.${pro ductMinorV ersion}.${ productRev }"
  8       def hc Room = '32 42078'
  9       def da teString =  new Date( currentBui ld.startTi meInMillis ).format(' yyyyMMdd_H Hmmss')
  10       def AR TIFACT_LOC ATION = "$ {WORKSPACE }/artifact s/${dateSt ring}"
  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 /index.htm l"
  18       def PH ANTOMJS_CD NURL="${MC CF_PUB_REP O_URL}/npm /sinopia/p hantomjs"
  19       def SA SS_BINARY_ NAME="linu x-x64-57"
  20       def SA SS_BINARY_ SITE="${MC CF_PUB_REP O_URL}/npm /sinopia/n ode-sass"
  21       def mc cf_git_rep o="https:/ /bitbucket .org/halfa ker/mccf_t as_core"
  22       def bu ildResultU UID=''
  23       def TA SWorkspace ="${WORKSP ACE}"
  24       def TA S_WEBUI="M CCF_EDI_TA S_WebUI"
  25       def TA S_BUILD_AR TIFACTS="B uild_Artif acts"
  26       def la stGitTag=' '
  27       def sc mtool="/op t/ibm/team concert/ja zz/scmtool s/eclipse/ scm.sh"
  28       def lo calTMP="${ WORKSPACE} /tmp"
  29     }
  30     agent an y
  31     stages{
  32       stage( 'Prepare w orkspace w ith source  code') {
  33         step s{
  34           sc ript{
  35              def bldENV =ENV?.trim ().toUpper Case()
  36              echo "dete rmine regi on for ${b ldENV}"
  37              def region =bldENV[0. .2]
  38              echo "dete rmine main  env for r egion ${re gion}, (ak a ${bldENV })"
  39              def mainEN V=bldENV[- 3..-1]
  40              echo "dete rmine acti on for ${b ldENV}, (a ka ${regio n}, ${main ENV})"
  41              switch(reg ion){
  42                case "AW S":
  43                  echo " AWS enviro nment, Pre pare Halfa ker worksp ace"
  44                  dir("$ {TAS_WEBUI }"){
  45                    getH alfakerCod e()
  46                  }
  47                  break
  48                case "ED E":
  49                case "MA G":
  50                  echo ( "Initializ e workspac e from RTC ")
  51                  if (!T GT_STREAM? .trim().to UpperCase( ).equals(" DEV")){
  52                    STAG ING_DIR="$ {WEB_BASED IR}/rtc/ta s"
  53                  }
  54                  teamco ncert([
  55                    buil dType: [
  56                      bu ildDefinit ion: "${bu ildDefinit ionId}",
  57                      va lue: 'buil dDefinitio n'
  58                    ]
  59                  ])
  60                  echo ( "Verify co mponent ($ {TAS_WEBUI }) exists" )
  61                  sh '''
  62                    if [ [ -d "${TA S_WEBUI}"  ]]
  63                    then
  64                      ec ho "Compon ent (${TAS _WEBUI}) e xists, saf e to proce ed"
  65                    else
  66                      fa il "FAIL:  No compone nt (${TAS_ WEBUI}) fo und"
  67                    fi
  68                  '''
  69                  echo " EDE enviro nment, det ermine SRC _STREAM"
  70                  if(mai nENV.equal s("DEV") & &  SRC_STR EAM?.trim( ).toUpperC ase().equa ls("HAF")) {
  71                    echo  "need to  get HAF co de"
  72                    dir( "${localTM P}"){
  73                      ge tHalfakerC ode()
  74                      ec ho "need t o check la stGitCommi t against  lastGitTag "
  75                    }
  76                    dir( "${TAS_WEB UI}"){
  77                      sh  'cp -p .p roject ../ taswebui.p roject'
  78                      sh  'rsync -a cvWh "${lo calTMP}/"  . --exclud e ".git" - -del'
  79                      sh  'mv ../ta swebui.pro ject .proj ect'
  80                    }
  81                  }
  82                  break
  83                default:
  84                  echo " local envi ronment, P repare Hal faker work space"
  85                  dir("$ {TAS_WEBUI }"){
  86                    getH alfakerCod e()
  87                  }
  88              }
  89           }
  90         }
  91       }
  92       stage( 'Pre-Build  Setup'){
  93         step s{
  94           ec ho ("creat e artifact  location  for jenkin s (${ARTIF ACT_LOCATI ON})")
  95           sh  'mkdir -p  ${ARTIFAC T_LOCATION }'
  96  
  97           ec ho ("prepa re npm")
  98           ec ho 'npm ca che clean  --force'
  99           sh  'npm cach e clean -- force'
  100  
  101           sh  'sudo npm  set regis try ${NPM_ REGISTRY}  -g'
  102           sh  'sudo npm  set phant omjs_cdnur l ${PHANTO MJS_CDNURL } -g'
  103           sh  'sudo npm  config de lete phant omjs_downl oadurl -g'
  104           sh  'sudo npm  set sass_ binary_nam e ${SASS_B INARY_NAME } -g'
  105           sh  'sudo npm  set sass_ binary_sit e ${SASS_B INARY_SITE } -g'
  106  
  107           ec ho ("set p rogress ba rs to fals e")
  108           sh  'sudo npm  set progr ess=false  -g'
  109           sh  'npm conf ig list'
  110           ec ho "set fi nal packag eVersion"
  111           di r("${TAS_W EBUI}"){
  112              script{
  113                if(ENV?. trim().toU pperCase() .startsWit h("EDE") | | ENV?.tri m().toUppe rCase().st artsWith(" MAG")){
  114                  echo " building i n EDE, do  not use gi t commit i n packageV ersion"
  115                  packag eVersion=" ${packageV ersion}_${ dateString }"
  116                }
  117                else {
  118                  echo " git build"
  119                  lastCo mmitID=get LastGitCom mit()
  120                  echo " last commi t is ${las tCommitID} "
  121                  if(las tCommitID? .trim()){
  122                      pa ckageVersi on="${pack ageVersion }_${lastCo mmitID}"
  123                  }
  124                }
  125                echo "fi nal packag eVersion f or tag ${p ackageVers ion}"
  126                packageN ame=getPac kageName()
  127                DIST_OUT PUT_FILENA ME="${pack ageName}_$ {packageVe rsion}.tar .gz"
  128                echo "bu ilding for  package $ {DIST_OUTP UT_FILENAM E}"
  129                echo "up dating met adata for  ${index}"
  130                updateIn dexMetaDat a()
  131              }
  132              echo "exec ute npm in stall"
  133              sh 'npm in stall 2>&1  | tee npm _install.l og'
  134  
  135              echo "chec k npm_inst all.log fo r download  syntax"
  136              script{
  137                if (file Exists("np m_install. log")){
  138                  def ST R_TEST=che ckNpmInsta llLog("npm _install.l og")
  139                  if(STR _TEST?.tri m().toUppe rCase().st artsWith(" PROCEED")) {
  140                    echo  "${STR_TE ST}"
  141                  }
  142                  else{
  143                    curr entBuild.r esult='FAI LED'
  144                    erro r("FAIL: n pm install  is trying  to downlo ad content ")
  145                  }
  146                }
  147              }
  148              echo "chec k dependen cies"
  149              sh 'check- dependenci es --verbo se |& tee  npm-check- dependenci es.log'
  150              echo "chec k npm-chec k-dependen cies for ' not instal led'"
  151              script{
  152                if (file Exists("np m-check-de pendencies .log")){
  153                  def ST R_TEST=che ckDependen ciesLog("n pm-check-d ependencie s.log")
  154                  if(STR _TEST?.tri m().toUppe rCase().st artsWith(" PROCEED")) {
  155                    echo  "${STR_TE ST}"
  156                  }
  157                  else{
  158                    curr entBuild.r esult='FAI LED'
  159                    erro r("FAIL: d ependency  check fail ed")
  160                  }
  161                }
  162              }
  163           }
  164         }
  165       }
  166       stage( 'Pre-Build  Tests'){
  167         envi ronment{
  168           se leniumTest Dir = "nod e_modules/ protractor /node_modu les/webdri ver-manage r/selenium "
  169           se leniumTest Path = "${ WORKSPACE} /${TAS_WEB UI}/${sele niumTestDi r}"
  170         }
  171         step s{
  172           ec ho "execut e ng test  for ${TAS_ WEBUI}"
  173           di r("${TAS_W EBUI}"){
  174              echo "exec ute ng tes t"
  175              sh 'npm ru n test'
  176  
  177              echo ("Ver ify unit t est summar y exists")
  178              sh '''
  179                if [[ -f  "unit_tes t_report_s ummary.htm l" ]]
  180                then
  181                  echo " move unit_ test_repor t_summary. html to ($ {WORKSPACE })"
  182                  mv "un it_test_re port_summa ry.html" " ${WORKSPAC E}"
  183                else
  184                  echo " no unit_te st_report_ summary.ht ml found"
  185                fi
  186              '''
  187              echo ("Ver ify covera ge tests e xist")
  188              sh '''
  189                if [[ -d  "coverage " ]]
  190                then
  191                  echo " move tests  to (${WOR KSPACE})"
  192                  mv "co verage" "$ {WORKSPACE }"
  193                else
  194                  echo " no coverag e tests fo und"
  195                fi
  196              '''
  197              echo "crea te seleniu m test dir ectory"
  198              sh " if [[  -d ${sele niumTestPa th} ]]; th en echo 'd irectory e xists'; el se mkdir - p ${seleni umTestPath };fi"
  199  
  200              echo "exec ute e2e te sts"
  201              sh 'npm ru n e2e'
  202  
  203              echo ("Ver ify e2e te st results  exist")
  204              sh '''
  205                if [[ -d  "e2e/repo rts" ]]
  206                then
  207                  echo " move tests  to (${WOR KSPACE})"
  208                  mv "e2 e/reports"  "${WORKSP ACE}/e2e_r esults"
  209                else
  210                  echo " no e2e tes t results  found"
  211                fi
  212                if [[ -f  "e2e/logs /testresul ts.xml" ]]
  213                then
  214                  echo " move tests  to (${WOR KSPACE})"
  215                  mv "e2 e/logs/tes tresults.x ml" "${WOR KSPACE}/e2 e_testresu lts.xml"
  216                else
  217                  echo " no e2e tes t results  found"
  218                fi
  219              '''
  220           }
  221         }
  222       }
  223       stage( 'Build'){
  224         step s{
  225           ec ho "build  the projec t ${TAS_WE BUI}"
  226           di r ("${TAS_ WEBUI}"){
  227              sh 'npm ru n build'
  228              script{
  229                if (file Exists("${ WORKSPACE} /${TAS_WEB UI}/dist/i ndex.html" )) {
  230                  echo " ${WORKSPAC E}/${TAS_W EBUI}/dist /index.htm l created,  ready to  package"
  231                } 
  232                else {
  233                  error( "FAIL: ${W ORKSPACE}/ ${TAS_WEBU I}/dist/in dex.html n ot ready")
  234                }
  235              }
  236           }
  237         }
  238       }
  239       stage( 'Prepare P ackage') {
  240         step s{
  241           ec ho ("Prepa re to pack age ${DIST _OUTPUT_FI LENAME}")
  242           di r ("${TAS_ WEBUI}"){
  243              echo ("pac kaging ${p ackageName } for dist ribution")
  244              script{
  245                DIST_OUT PUT_FILE=" ${WORKSPAC E}/${DIST_ OUTPUT_FIL ENAME}"
  246                echo "pa ckaging ${ DIST_OUTPU T_FILE}"
  247                sh "tar  czf ${DIST _OUTPUT_FI LE} -C ${W ORKSPACE}/ ${TAS_WEBU I}/dist/ . "
  248                echo "ve rify packa ge created "
  249                if (file Exists("${ DIST_OUTPU T_FILE}"))  {
  250                  echo " ${DIST_OUT PUT_FILE}  created, r eady to de ploy"
  251                } 
  252                else {
  253                  error( "FAIL: ${D IST_OUTPUT _FILE} not  created")
  254                }
  255              }
  256           }
  257         }
  258       }
  259       stage( 'Stage Pac kage') {
  260         step s{
  261           ec ho "stage  the packag ed distrib ution (${D IST_OUTPUT _FILE}) fo r ${packag eName}"
  262           st ageLatestA rtifact("$ {DIST_OUTP UT_FILE}")
  263         }
  264       }
  265     }
  266     post{
  267       always {
  268         echo  "POST alw ays: all t asks are c ompleted,  collecting  environme nt variabl es to ${WO RKSPACE}/$ {BUILD_TAG }.log"
  269         sh ' printenv > > $WORKSPA CE/$BUILD_ TAG.log'
  270         echo  "POST alw ays: archi ving all l ogs and ar tifacts sp ecified"
  271         publ ishHTML ta rget: [all owMissing:  true, alw aysLinkToL astBuild:  false, kee pAll: true , reportDi r: 'covera ge', repor tFiles: 'i ndex.html' , reportNa me: 'CodeC overage',  reportTitl es: '']
  272         juni t allowEmp tyResults:  true, hea lthScaleFa ctor: 1.0,  testResul ts: 'e2e_t estresults .xml'
  273       }
  274       succes s{
  275         echo  'POST suc cess: chec k environm ent to det ermine com mit action s'
  276         scri pt {
  277           de f myENV="$ {ENV}"
  278           de f subENV=m yENV[0..2]
  279           de f EDE_ARTI FACT_LOCAT ION = "${W ORKSPACE}/ ${TAS_BUIL D_ARTIFACT S}/${packa geVersion} "
  280           ec ho "POST s uccess: de termine pr oper commi t action f or ${myENV }, (aka ${ subENV})"
  281           sw itch(subEN V.toUpperC ase()){
  282              case "AWS" :
  283                echo "PO ST success : AWS envi ronment, u se git to  tag this b uild"
  284                gitTagBu ild()
  285                echo "PO ST success : in AWS,  make hipch at notific ation"
  286                notifyHi pchat(curr entBuild.r esult,hcRo om)
  287                break
  288              case "EDE" :
  289              case "MAG" :
  290                echo "PO ST success : copy pac kaged arti fact (${DI ST_OUTPUT_ FILE}) to  ${TAS_BUIL D_ARTIFACT S}"
  291                sh """
  292                  mkdir  -p "${EDE_ ARTIFACT_L OCATION}"
  293                  cp "${ DIST_OUTPU T_FILE}" " ${EDE_ARTI FACT_LOCAT ION}/"
  294                  echo " POST succe ss: check  ${EDE_ARTI FACT_LOCAT ION}/${DIS T_OUTPUT_F ILENAME}"
  295                  if [[  -f "${EDE_ ARTIFACT_L OCATION}/$ {DIST_OUTP UT_FILENAM E}" ]]
  296                  then
  297                    echo  "POST suc cess: Arti fact (${ED E_ARTIFACT _LOCATION} /${DIST_OU TPUT_FILEN AME}) exis ts, safe t o proceed"
  298                  else
  299                    fail  "FAIL: PO ST success : No artif act (${EDE _ARTIFACT_ LOCATION}/ ${DIST_OUT PUT_FILENA ME}) found "
  300                  fi
  301                 """
  302                echo "cl eanup prio r to check in and del iver"
  303                dir("${T AS_WEBUI}" ){
  304                  sh "mv  ${index}. bak ${inde x}"
  305                  sh 'rm  -rf node_ modules'
  306                  sh 'rm  -rf e2e/l ogs'
  307                  sh 'rm  -rf dist'
  308                  sh 'fi nd . -name  "*.log" - type f -de lete'
  309                }
  310                rtcCheck in()
  311                rtcDeliv er()
  312                echo "PO ST success : send ema il notific ation"
  313                notifyBu ildStatus( currentBui ld.result)
  314              break
  315              default:
  316               echo "POS T success:  local env ironment,  send no no tices"
  317               echo "POS T success:  local env ironment,  do not com mit any ta g"
  318           }
  319         }
  320         echo  "POST suc cess: coll ecting con sole log"
  321         getC onsoleLog( )
  322         arch iveArtifac ts allowEm ptyArchive : true, ar tifacts: ' **/*.log,  *.html, *. tar.gz, e2 e_testresu lts.xml' ,  onlyIfSuc cessful: f alse
  323         echo  'POST suc cess: Perf orming cle anup tasks  after bui ld success '
  324         dele teDir()
  325       }
  326       failur e{
  327         scri pt{
  328           if (BUILD_URL .toLowerCa se().conta ins("aws") ){
  329              echo "POST  failure:  in AWS, ma ke hipchat  notificat ion"
  330              notifyHipc hat(curren tBuild.res ult,hcRoom )
  331           }
  332           if (ENV.toLow erCase().c ontains("l ocal")){
  333                echo "PO ST failure : local en vironment,  send no n otices"
  334           }
  335           el se{
  336              echo "POST  failure:  send email  notificat ion"
  337              notifyBuil dStatus(cu rrentBuild .result)
  338           }
  339         }
  340         echo  "POST fai lure: coll ecting con sole log"
  341         getC onsoleLog( )
  342         arch iveArtifac ts allowEm ptyArchive : true, ar tifacts: ' **/*.log,  *.html, *. tar.gz, e2 e_testresu lts.xml' ,  onlyIfSuc cessful: f alse
  343         echo  'POST fai lure: Perf orming cle anup tasks  for build  failure'
  344         dele teDir()
  345       }
  346     }
  347   }
  348   // RTC ste ps for che ckin and d eliver
  349   def rtcChe ckin(){
  350     withCred entials([u sernamePas sword(cred entialsId:  'RTC_BUIL D', userna meVariable : 'rtcUser ', passwor dVariable:  'rtcPass' )]) {
  351     // avail able as an  env varia ble, but w ill be mas ked if you  try to pr int it out  any which  way
  352       def MY HOSTNAME=g etHostname ()
  353       def la stBuildDat e=new Date (currentBu ild.startT imeInMilli s).format( 'MMM dd, y yyy HH:mm: ss Z')
  354       def ve rsionStrin g="version : ${packag eVersion}"
  355       def bu ildDateStr ing="lastB uildDate:  ${lastBuil dDate}"
  356       def di stribution String="di stribution FileName:  <staging_u rl>/${DIST _OUTPUT_FI LENAME}"
  357       def co mmitCommen t = /"jenk ins-${JOB_ BASE_NAME} -${BUILD_N UMBER}-${M YHOSTNAME} ,${version String}, $ {buildDate String}, $ {distribut ionString} "/
  358       def wo rkitem = " ${RTC_WORK ITEM}"
  359       def co mponents=  ["${TAS_WE BUI}"]
  360  
  361       echo " show scm s tatus"
  362       sh """
  363         ${sc mtool} sho w status - u ${rtcUse r} -P ${rt cPass} -v  --all -d $ {TASWorksp ace}
  364         echo  "----- -- --- -----  ----- ---- -"
  365       """
  366       
  367       echo " prepare to  checkin c omponents"
  368       for (c omponent i n componen ts){
  369         echo  "loop thr ough each  file in $c omponent"
  370         sh " ""
  371           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}/{} \ \;
  372         """
  373         echo  "${scmtoo l} checkin  $componen t/*"
  374         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/*"
  375         echo  "----- -- --- -----  ----- ---- -"
  376       }
  377       // the  following  is not va lid until  rtc 6.0.4
  378       //step ([$class:  'RTCPostBu ildDeliver Publisher' , failOnEr ror: true] )
  379     }
  380   }
  381  
  382   def rtcDel iver(){
  383       withCreden tials([use rnamePassw ord(creden tialsId: ' RTC_BUILD' , username Variable:  ' AI ', passwor dVariable:  ' AI ')]) {
  384     // avail able as an  env varia ble, but w ill be mas ked if you  try to pr int it out  any which  way
  385       def wo rkitem = " ${RTC_WORK ITEM}"
  386       echo " show scm s tatus"
  387       sh """
  388         ${sc mtool} sho w status - u ${rtcUse r} -P ${rt cPass} -v  --all -d $ {TASWorksp ace}
  389         echo  "----- -- --- -----  ----- ---- -"
  390       """
  391       echo " RTC ${rtcU ser} deliv er "
  392       def de liverStatu s=sh (
  393       script : "${scmto ol} delive r -u ${rtc User} -P $ {rtcPass}  -v",
  394       return Status: tr ue
  395       )
  396       if (de liverStatu s == 0 ||  deliverSta tus == 52  || deliver Status ==  53){
  397         echo  "Deliver  succeed"
  398         retu rn 0
  399       }
  400       else {
  401         retu rn deliver Status;
  402       }
  403       // the  following  is not va lid until  rtc 6.0.4
  404       //step ([$class:  'RTCPostBu ildDeliver Publisher' , failOnEr ror: true] )
  405     }
  406   }
  407  
  408   def rtcBas eline(){
  409       withCreden tials([use rnamePassw ord(creden tialsId: ' RTC_BUILD' , username Variable:  ' AI ', passwor dVariable:  ' AI ')]) {
  410     // avail able as an  env varia ble, but w ill be mas ked if you  try to pr int it out  any which  way
  411       echo " RTC list w orkspaces  "
  412       def wo rkspaceLis t=sh (
  413       script : "${scmto ol} list w orkspaces  -r local - v",
  414       return Stdout: tr ue
  415       ).trim ()
  416  
  417       echo " workspace:  ${workspa ceList}"
  418  
  419       echo " RTC ${rtcU ser} creat e baseline  "
  420       sh """
  421         ${sc mtool} cre ate baseli ne -u ${rt cUser} -P  ${rtcPass}  --all ${w orkspaceLi st} ${pack ageVersion
  422       """
  423       // the  following  is not va lid until  rtc 6.0.4
  424       //step ([$class:  'RTCPostBu ildDeliver Publisher' , failOnEr ror: true] )
  425     }
  426   }
  427  
  428   // load wo rkspace
  429   def getHal fakerCode( ){
  430     sh """
  431       echo " cache cred entials 'c ache --tim eout 3600' "
  432       git co nfig --glo bal creden tial.helpe r 'cache - -timeout 3 600'
  433       git co nfig --glo bal core.a utocrlf fa lse
  434     """
  435     git cred entialsId:  'jenkins_ build', ur l: "${mccf _git_repo} ", poll: f alse
  436     echo ("g et last gi t tag")
  437     lastGitT ag=gitDesc ribe()
  438     def last Commit=get LastGitCom mit()
  439     echo ("c heck lastG itTag (${l astGitTag} )")
  440     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")
  441     if ( las tGitTag?.t rim() ){
  442       echo ( "Ready to  build ${la stGitTag}  (${lastCom mit})")
  443     }
  444     else {
  445       error( "FAIL: no  source pul led from $ {mccf_git_ repo}")
  446     }
  447    }
  448  
  449    // git fu nctions
  450   def getCha ngesets(){
  451       def ch angeLogSet s = curren tBuild.cha ngeSets
  452       echo " reviewing  changesets :"
  453       def co mmitMessag e=""
  454       for (i nt i = 0;  i < change LogSets.si ze(); i++)  {
  455           de f entries  = changeLo gSets[i].i tems
  456           fo r (int j =  0; j < en tries.leng th; j++) {
  457                def entr y = entrie s[j]
  458                commitMe ssage="${c ommitMessa ge} \n ${e ntry.commi tId} by ${ entry.auth or} on ${n ew Date(en try.timest amp)}"
  459                echo "${ entry.comm itId} by $ {entry.aut hor} on ${ new Date(e ntry.times tamp)}: ${ entry.msg} "
  460                def file s = new Ar rayList(en try.affect edFiles)
  461                for (int  k = 0; k  < files.si ze(); k++)  {
  462                    def  file = fil es[k]
  463                    echo  "  ${file .editType. name} ${fi le.path}"
  464                }
  465           }
  466       }
  467       return  "${commit Message}"
  468   }
  469  
  470   def gitDes cribe(){
  471     echo "ge tting last  git tag"
  472     def MYIN FO
  473     def tagE xists=sh(r eturnStdou t: true, s cript: 'gi t tag --li st').trim( )
  474     if ( tag Exists?.tr im() ) {
  475       MYINFO =sh(return Stdout: tr ue, script : 'git des cribe').tr im()
  476     }
  477     else {
  478       MYINFO =sh(return Stdout: tr ue, script : 'git des cribe --al ways').tri m()
  479     }
  480     echo ("w e need to  parse ${MY INFO} to d etermine i f the late st tag is  the latest  commit")
  481     MYINFO
  482   }
  483  
  484   def getLas tGitCommit (){
  485     echo "ge tting last  git commi t"
  486     def LAST _COMMIT
  487     LAST_COM MIT = sh (
  488       script : 'git log  -n 1 $BRA NCH_NAME - -pretty=fo rmat:"%H"' ,
  489       return Stdout: tr ue
  490     ).trim()
  491     echo ("t he last co mmit is ${ LAST_COMMI T[0..6]}")
  492     LAST_COM MIT[0..6]
  493   }
  494  
  495   def gitTag Build(){
  496       withCreden tials([use rnamePassw ord(creden tialsId: ' jenkins_bu ild', pass wordVariab le: ' AI ', usernam eVariable:  ' AI ')]) {
  497       def MY HOSTNAME=g etHostname ()
  498       def co mmit_messa ge = /"jen kins-${JOB _BASE_NAME }-${BUILD_ NUMBER}-${ MYHOSTNAME }"/
  499       echo " set the us er.name"
  500       sh 'gi t config u ser.name " ${jenkinsU ser}"'
  501       echo " set the us er.email"
  502       def uE mail = /"m ccfsystema dmins@half aker.com"/  
  503       sh """
  504         git  config use r.email ${ uEmail}
  505       """
  506       sh 'gi t config a lias.versi onlog "not es --ref=v ersionlog  append"'
  507       sh """ git config  --add rem ote.origin .push '+re fs/notes/* :refs/note s/*'"""
  508       sh """ git config  --add rem ote.origin .fetch '+r efs/notes/ *:refs/not es/*'"""
  509       sh 'ca t .git/con fig'
  510       echo " append ver sion note  to this co mmit"
  511       addGit VersionLog ()
  512       echo " tag this c ommit"
  513       sh """
  514         git  tag -a ${p ackageVers ion} -m '$ {commit_me ssage}' ${ lastCommit ID}
  515         echo  "push cha nges to re mote"
  516         git  config pus h.default  simple
  517         git  push origi n HEAD:mas ter --tags
  518       """
  519     }
  520   }
  521  
  522   def addGit VersionLog (){
  523     def last BuildDate= new Date(c urrentBuil d.startTim eInMillis) .format('M MM dd, yyy y HH:mm:ss  Z')
  524     def vers ionString= "version:  ${packageV ersion}"
  525     def buil dDateStrin g="lastBui ldDate: ${ lastBuildD ate}"
  526     def dist ributionSt ring="dist ributionFi leName: <s taging_url >/${DIST_O UTPUT_FILE NAME}"
  527     sh """
  528       git ve rsionlog $ {lastCommi tID} -m "$ {versionSt ring}, ${b uildDateSt ring}, ${d istributio nString}"
  529     """
  530   }
  531  
  532   // helper  functions
  533   def getHos tname(){
  534     def THIS HOSTNAME
  535     if(isUni x()){
  536       THISHO STNAME = s h (
  537         scri pt: 'hostn ame',
  538         retu rnStdout:  true
  539       ).trim ()
  540     }
  541     else {
  542       THISHO STNAME = b at (
  543         scri pt: 'hostn ame',
  544         retu rnStdout:  true
  545       ).trim ()
  546     }
  547     THISHOST NAME
  548   }
  549  
  550   def getPac kageName() {
  551     echo "ge tting pack age name"
  552     def MYNA ME
  553     MYNAME =  sh (
  554         scri pt: 'npm r un env | g rep npm_pa ckage_name  | cut -d  \"=\" -f 2 ',
  555         retu rnStdout:  true
  556       ).trim ()
  557     MYNAME
  558   }
  559  
  560   def update IndexMetaD ata(){
  561     def last BuildDate= new Date(c urrentBuil d.startTim eInMillis) .format('M MM dd, yyy y HH:mm:ss  Z')
  562     def meta Data=["dis tributionF ileName":" ${DIST_OUT PUT_FILENA ME}", "las tBuildDate ":"${lastB uildDate}" , "version ":"${packa geVersion} " ]
  563     echo 'ba ckup the i ndex file  bfore edit ing'
  564     sh "cp $ {index} ${ index}.bak "
  565     for (kv  in mapToLi st(metaDat a)){
  566        def n ame=kv[0]
  567        def c ontent=kv[ 1]
  568        echo  "update me ta tag nam e=\"${name }\", conte nt=\"${con tent}\""
  569        sh "" "
  570          sed  -i '/<hea d>/a <meta  name=\"${ name}\" co ntent=\"${ content}\"  >' "${ind ex}"
  571        """       
  572     }
  573   }
  574  
  575   def checkN pmInstallL og(log){
  576     echo "ch ecking npm  install l og for 'Do wnloading. *github'"
  577     def MYRE SULT
  578     MYRESULT  = sh (
  579         scri pt: """
  580           if  grep -Exq  "Download ing.*githu b" ${log}
  581           th en
  582              echo "FAIL ED: unauth orized dow nload"
  583           el se
  584              echo "PROC EED: Nothi ng incrimi nating fou nd in log"
  585           fi
  586           "" ",
  587         retu rnStdout:  true
  588       ).trim ()
  589     return M YRESULT
  590   }
  591  
  592   def checkD ependencie sLog(log){
  593     echo "ch ecking  lo g for 'not  installed '"
  594     def MYRE SULT
  595     MYRESULT  = sh (
  596         scri pt: """
  597           if  grep -Exq  ".*not in stalled.*"  ${log}
  598           th en
  599              echo "FAIL ED: packag es not ins talled"
  600           el se
  601              echo "PROC EED: All p ackages in stalled"
  602           fi
  603           "" ",
  604         retu rnStdout:  true
  605       ).trim ()
  606     return M YRESULT
  607   }
  608  
  609   def stageL atestArtif act(artifa ct){
  610       echo " stage the  latest bui ld artifac t(${artifa ct}) for d eployment"
  611       def ar tifact_nam e= artifac t.tokenize ('/').last ()
  612       def st aging = ST AGING_DIR. trim().toL owerCase()
  613       def la test = "${ WEB_BASEDI R}/latest_ dev"
  614       echo " check for  TGT_STREAM "
  615       if(env .TGT_STREA M && env.T GT_STREAM? .trim()){
  616           ec ho "TGT_ST REAM found  (${TGT_ST REAM})"
  617           de f link=TGT _STREAM.tr im().toLow erCase()
  618           la test = "${ WEB_BASEDI R}/latest_ ${link}"
  619       }
  620       try {
  621           ec ho "check  ${staging}  directory  exist"
  622           sh  "[[ -d ${ staging} ] ] || sudo  mkdir -p $ {staging}"
  623           ec ho "copy $ {artifact}  to ${stag ing}/"
  624           sh  "sudo cp  ${artifact } ${stagin g}/"
  625           ec ho "create  symbolic  link to st aged artif act"
  626           sh  "sudo ln  -sfn ${sta ging}/${ar tifact_nam e} ${lates t}"
  627           ec ho "verify  link crea ted"
  628           de f linkExis ts=sh (
  629                script:  "readlink  ${latest}" ,
  630                returnSt dout: true
  631                ).trim()
  632           sh  """
  633                if [[ -n  "${linkEx ists}" ]];  then
  634                    echo  "link exi sts for ${ latest}"
  635                else
  636                    echo  "link not  found ${l atest}"
  637                fi
  638           "" "
  639       } catc h(Exceptio n e){
  640           ec ho "someth ing bad ha ppened whi le staging  artifact,  throw and  fail"
  641           ec ho e.toStr ing()
  642           th row e
  643       }
  644   }
  645   // notifyH ipchat
  646   // will se nd color c oded notif ications t o hipchat
  647   //
  648   def notify Hipchat(St ring build Status = ' STARTED',  String hcR oom = '324 2078') {
  649   // build s tatus of n ull means  successful
  650     buildSta tus =  bui ldStatus ? : 'SUCCESS FUL'
  651  
  652     def last Build = cu rrentBuild .getPrevio usBuild()
  653  
  654     // Defau lt values
  655     def colo r = 'RED'
  656     def colo rCode = '# FF0000'
  657     def subj ect = "${b uildStatus }: Job '${ env.JOB_NA ME} [${env .BUILD_NUM BER}]'"
  658     def summ ary = "${s ubject} ($ {env.BUILD _URL})"
  659  
  660       // Ove rride defa ult values  based on  build stat us
  661     if (buil dStatus ==  'STARTED' ) {
  662       color  = 'YELLOW'
  663       colorC ode = '#FF FF00'
  664     } 
  665     else if  (buildStat us == 'SUC CESSFUL')  {
  666       color  = 'GREEN'
  667       colorC ode = '#00 FF00'
  668       if( la stBuild &&  lastBuild .getResult ().toStrin g()=="FAIL URE" ){
  669         buil dStatus =  'FIXED'
  670       }
  671     } 
  672     else if  (buildStat us == 'ABO RTED') {
  673       color  = 'PURPLE'
  674       colorC ode = '#80 0080'
  675     }
  676     else if  (buildStat us == 'UNS TABLE') {
  677       color  = 'GRAY'
  678       colorC ode = '#80 8080'
  679     }
  680     else {
  681       color  = 'RED'
  682       colorC ode = '#FF 0000'
  683     }
  684    
  685      // Send  notificat ions
  686     echo "se nd notice  of ${build Status} to  hipchat r oom: ${hcR oom}"
  687     def hcMe ssage=getC hangesets( )
  688     if(build Status ==  'SUCCESSFU L'){
  689       echo " only send  notice if  previous b uild faile d"
  690       if( la stBuild &&  lastBuild .getResult ().toStrin g()=="FAIL URE" ){
  691         echo  "the prev ious build  ${lastBui ld.getId() } failed,  send updat e"
  692         hipc hatSend (
  693           co lor: color
  694           cr edentialId : 'jenkins _hc_notifi cation', 
  695           me ssage: sum mary + ":  changesets :  " + hcM essage, 
  696           no tify: true
  697           ro om: hcRoom
  698           se ndAs: 'jen kins_build ', 
  699           te xtFormat:  false, 
  700           v2 enabled: t rue
  701         )
  702       }
  703       else {
  704         echo  "the prev ious build  " + lastB uild.getRe sult().toS tring()
  705       }
  706     }
  707     else {
  708       echo " this build  ${buildSt atus}"
  709       hipcha tSend (
  710         colo r: color,
  711         cred entialId:  'jenkins_h c_notifica tion',
  712         mess age: summa ry + ": ch angesets:   " + hcMes sage,
  713         noti fy: true,
  714         room : hcRoom,
  715         send As: 'jenki ns_build',
  716         text Format: fa lse,
  717         v2en abled: tru e
  718       )
  719     }
  720   }
  721  
  722   def notify BuildStatu s(String b uildStatus  = 'STARTE D') {
  723     // build  status of  null mean s successf ul
  724     buildSta tus =  bui ldStatus ? : 'SUCCESS FUL'
  725  
  726   //recipien tProviders  (optional )
  727   //$class:  CulpritsRe cipientPro vider
  728   //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.
  729   //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  
  730   //was a fa ilure it a lso includ es the cul prit list  from there .
  731  
  732   //$class:  Developers RecipientP rovider
  733   //Sends em ail to all  the peopl e who caus ed a chang e in the c hange set.
  734  
  735   //$class:  FailingTes tSuspectsR ecipientPr ovider
  736   //Sends em ail to the  list of u sers suspe cted of ca using a un it test to  begin fai ling.
  737   //This lis t includes  committer s and requ estors of  the build  where the  test began  to fail,
  738   //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.
  739  
  740   //$class:  FirstFaili ngBuildSus pectsRecip ientProvid er
  741   //Sends em ail to the  list of u sers suspe cted of ca using the  build to b egin faili ng.
  742  
  743   //$class:  ListRecipi entProvide r
  744   //Sends em ail to the  list of r ecipients  defined in  the "Proj ect Recipi ent List."
  745  
  746   //$class:  RequesterR ecipientPr ovider
  747   //Sends em ail to the  user who  initiated  the build.
  748  
  749   //$class:  UpstreamCo mitterReci pientProvi der
  750   //Sends em ail to the  list of u sers who c ommitted c hanges in  upstream b uilds that  triggered  this buil d
  751   // Default  values            Li stRecipien tProvider
  752     def reci pients=[[$ class: 'Li stRecipien tProvider' ]]
  753     def subj ect = "${b uildStatus }: Job '${ env.JOB_NA ME} [${env .BUILD_NUM BER}]'"
  754     def repl yto = "${e nv.DEFAULT _REPLYTO}"
  755     def mime Type = "te xt/html"
  756     def send to = "${en v.DEFAULT_ RECIPIENTS }"
  757     def deta ils = """
  758       <p>Job : '${env.J OB_NAME} b uild: [${e nv.BUILD_N UMBER}]':< /p>
  759       <p>Che ck console  output at  "<a href= "${env.BUI LD_URL}">$ {env.JOB_N AME} [${en v.BUILD_NU MBER}]</a> "</p>
  760       """
  761  
  762       // Ove rride defa ult values  based on  build stat us
  763     if (buil dStatus ==  'STARTED'  || buildS tatus == ' SUCCESSFUL ' || build Status ==  'FIXED') {
  764       recipi ents = [[$ class: 'De velopersRe cipientPro vider']]
  765     } 
  766    
  767     else if  (buildStat us == 'ABO RTED' || b uildStatus  == 'UNSTA BLE') {
  768       recipi ents = [[$ class: 'De velopersRe cipientPro vider']]
  769     }
  770     else {
  771       echo " unknown st atus"
  772       recipi ents = [[$ class: 'Cu lpritsReci pientProvi der'], [$c lass: 'Req uesterReci pientProvi der']]
  773     }
  774   //examples
  775   //Notify C ulprits an d Requeste r via defa ult EMail  plugin
  776   //step([$c lass: 'Mai ler', noti fyEveryUns tableBuild : true, re cipients:  emailextre cipients([ [$class: ' CulpritsRe cipientPro vider'], [ $class: 'R equesterRe cipientPro vider']])] )
  777  
  778   //Send an  email to a bc plus an y addresse s returned  by the pr oviders
  779   //emailext  body: 'A  Test EMail ', 
  780   //          recipient Providers:  [[$class:  'Develope rsRecipien tProvider' ], [$class : 'Request erRecipien tProvider' ]], 
  781   //          subject:  'Test', 
  782   //          to: 'abc'
  783     echo "se nd email t o recipien ts (${reci pients}) f or ${build Status}"
  784     echo """
  785         subj ect: ${sub ject},
  786         body : ${detail s},
  787         reci pientProvi ders: ${re cipients},
  788         repl yTo: ${rep lyto},
  789         to:  ${sendto}
  790         """
  791     mail (
  792         body : details,  
  793         cc:  'lee.benha rt@halfake r.com', 
  794         mime Type: 'tex t/html', 
  795         repl yTo: reply to, 
  796         subj ect: subje ct, 
  797         to:  sendto
  798         )
  799   }
  800  
  801   //save log  to worksp ace
  802   def getCon soleLog(){
  803      //JENKI NS_HOME=/v ar/lib/jen kins
  804       //JENK INS_URL=ht tp://aws-m aster.mccf .halfakerl abs.com:80 80/
  805       //BUIL D_URL=http ://aws-mas ter.mccf.h alfakerlab s.com:8080 /job/MCCF_ TAS/job/MC CF_TAS_Cor e/512/
  806       //JOB_ URL=http:/ /aws-maste r.mccf.hal fakerlabs. com:8080/j ob/MCCF_TA S/job/MCCF _TAS_Core/
  807       //log  location i s /var/lib /jenkins/j obs/MCCF_T AS/jobs/MC CF_TAS_Cor e/builds/5 12
  808     echo "ge tConsoleLo g: prepare  logfilena me to get  console lo g"
  809     def logF ilename="$ {JOB_URL}"
  810     def work spaceLog=" ${WORKSPAC E}/${JOB_B ASE_NAME}_ ${BUILD_NU MBER}_cons ole.log"
  811     echo "ge tConsoleLo g: console  log is ${ logFilenam e} (same a s job url) "
  812     logFilen ame=logFil ename.trim ().replace ("${JENKIN S_URL}","$ {JENKINS_H OME}/")
  813     echo "ge tConsoleLo g: console  log is ch anged to $ {logFilena me}"
  814     logFilen ame=logFil ename.trim ().replace All("job", "jobs")
  815     echo "ge tConsoleLo g: console  log is ch anged agai n to ${log Filename}"
  816     logFilen ame="${log Filename}b uilds/${BU ILD_NUMBER }/log"
  817     echo "ge tConsoleLo g: console  log is fi nally  ${l ogFilename }"
  818     echo "ge tConsoleLo g: prepare  to write  to ${works paceLog}"
  819     sh """
  820       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"
  821       sed -e  "s,\\x1b\ \[3[0-9][m GKA],,gm;s ,\\x1b\\[1 A,,gm;s,\\ x1b\\[2K,, gm;" "tmp. log" > "${ workspaceL og}"
  822       rm "tm p.log"
  823       echo " getConsole Log: verif y ${worksp aceLog} re ady for ar chival"
  824       if [[  -f "${work spaceLog}"  ]]
  825       then
  826         echo  "getConso leLog: loc al console  log (${wo rkspaceLog }) exists,  safe to p roceed"
  827       else
  828         echo  "getConso leLog: No  local cons ole log ($ {workspace Log}) foun d"
  829       fi
  830     """
  831   }
  832   // Require d due to J ENKINS-274 21
  833   @NonCPS
  834   List<List< ?>> mapToL ist(Map ma p) {
  835     return m ap.collect  { it ->
  836       [it.ke y, it.valu e]
  837     }
  838   }