319. EPMO Open Source Coordination Office Redaction File Detail Report

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.

319.1 Files compared

# Location File Last Modified
1 MCCF_EDI_TAS_TASCore v2.0_Build_10.zip\MCCF_EDI_TAS_DevOps\mccf_devops mccfDevOps.Jenkinsfile Wed Apr 3 02:27:22 2019 UTC
2 MCCF_EDI_TAS_TASCore v2.0_Build_10.zip\MCCF_EDI_TAS_DevOps\mccf_devops mccfDevOps.Jenkinsfile Tue Apr 16 15:27:27 2019 UTC

319.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 1348
Changed 1 2
Inserted 0 0
Removed 0 0

319.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

319.4 Active regular expressions

No regular expressions were active.

319.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_d evops"
  22       def bu ildResultU UID=''
  23       def TA SWorkspace ="${WORKSP ACE}"
  24       def TA S_INFRA="M CCF_EDI_TA S_Infrastr ucture"
  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       def br anch_name= ''
  30     }
  31     agent an y
  32     options  { timestam ps() }
  33     stages{
  34       stage( 'Prepare w orkspace w ith source  code') {
  35         step s{
  36           sc ript{
  37              def bldENV =ENV?.trim ().toUpper Case()
  38              echo "dete rmine regi on for ${b ldENV}"
  39              def region =bldENV[0. .2]
  40              echo "dete rmine main  env for r egion ${re gion}, (ak a ${bldENV })"
  41              def mainEN V=bldENV[- 3..-1]
  42              echo "dete rmine acti on for ${b ldENV}, (a ka ${regio n}, ${main ENV})"
  43              switch(reg ion){
  44                case "AW S":
  45                  echo " AWS enviro nment, Pre pare Halfa ker worksp ace"
  46                  dir("$ {TAS_INFRA }"){
  47                    getH alfakerCod e()
  48                  }
  49                  break
  50                case "ED E":
  51                case "MA G":
  52                  echo ( "Initializ e workspac e from RTC ")
  53                  if (!T GT_STREAM? .trim().to UpperCase( ).equals(" DEV")){
  54                    STAG ING_DIR="$ {WEB_BASED IR}/rtc/ta s"
  55                  }
  56                  teamco ncert([
  57                    buil dType: [
  58                      bu ildDefinit ion: "${bu ildDefinit ionId}",
  59                      va lue: 'buil dDefinitio n'
  60                    ]
  61                  ])
  62                  echo ( "Verify co mponent ($ {TAS_INFRA }) exists" )
  63                  sh '''
  64                    if [ [ -d "${TA S_INFRA}"  ]]
  65                    then
  66                      ec ho "Compon ent (${TAS _INFRA}) e xists, saf e to proce ed"
  67                    else
  68                      fa il "FAIL:  No compone nt (${TAS_ INFRA}) fo und"
  69                    fi
  70                  '''
  71                  echo " EDE enviro nment, det ermine SRC _STREAM"
  72                  if(mai nENV.equal s("DEV") & &  SRC_STR EAM?.trim( ).toUpperC ase().equa ls("HAF")) {
  73                    echo  "need to  get HAF co de"
  74                    dir( "${localTM P}"){
  75                      ge tHalfakerC ode()
  76                      ec ho "need t o check la stGitCommi t against  lastGitTag "
  77                    }
  78                    dir( "${TAS_INF RA}"){
  79                      sh  'cp -p .p roject ../ taswebui.p roject'
  80                      sh  'rsync -a cvWh "${lo calTMP}/"  . --exclud e ".git" - -del'
  81                      sh  'mv ../ta swebui.pro ject .proj ect'
  82                    }
  83                  }
  84                  break
  85                default:
  86                  echo " local envi ronment, P repare Hal faker work space"
  87                  dir("$ {TAS_INFRA }"){
  88                    getH alfakerCod e()
  89                  }
  90              }
  91           }
  92         }
  93       }
  94     }
  95     post{
  96       always {
  97         echo  "POST alw ays: all t asks are c ompleted,  collecting  environme nt variabl es to ${WO RKSPACE}/$ {BUILD_TAG }_environm ent.log"
  98         sh ' printenv > > "${WORKS PACE}/${BU ILD_TAG}_e nvironment .log"'
  99         echo  "POST alw ays: archi ving all l ogs and ar tifacts sp ecified"
  100         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: '']
  101       }
  102       succes s{
  103         echo  'POST suc cess: chec k environm ent to det ermine com mit action s'
  104              script {
  105           de f myENV="$ {ENV}"
  106           de f subENV=m yENV[0..2]
  107           de f EDE_ARTI FACT_LOCAT ION = "${W ORKSPACE}/ ${TAS_BUIL D_ARTIFACT S}/${packa geVersion} "
  108           ec ho "POST s uccess: de termine pr oper commi t action f or ${myENV }, (aka ${ subENV})"
  109           sw itch(subEN V.toUpperC ase()){
  110              case "AWS" :
  111                echo "PO ST success : AWS envi ronment, u se git to  tag this b uild"
  112                gitTagBu ild()
  113                echo "PO ST success : in AWS,  make hipch at notific ation"
  114                notifyHi pchat(curr entBuild.r esult,hcRo om)
  115                break
  116              case "EDE" :
  117              case "MAG" :
  118                echo "PO ST success : Checkout  completed  - prepari ng for che ck-in"
  119                rtcCheck in()
  120                rtcDeliv er()
  121                             echo " POST succe ss: Check- in and del iver compl eted"
  122                //echo " POST succe ss: send e mail notif ication"
  123                //notify BuildStatu s(currentB uild.resul t)
  124              break
  125              default:
  126               echo "POS T success:  local env ironment,  send no no tices"
  127               echo "POS T success:  local env ironment,  do not com mit any ta g"
  128           }
  129         }
  130         echo  "POST suc cess: coll ecting con sole log"
  131         getC onsoleLog( )
  132         arch iveArtifac ts allowEm ptyArchive : true, ar tifacts: ' **/*.log,  *.html, *. tar.gz, e2 e_testresu lts.xml' ,  onlyIfSuc cessful: f alse
  133         echo  'POST suc cess: Perf orming cle anup tasks  after bui ld success '
  134         dele teDir()
  135       }
  136       failur e{
  137         scri pt{
  138           if (BUILD_URL .toLowerCa se().conta ins("aws") ){
  139              echo "POST  failure:  in AWS, ma ke hipchat  notificat ion"
  140              notifyHipc hat(curren tBuild.res ult,hcRoom )
  141           }
  142           if (ENV.toLow erCase().c ontains("l ocal")){
  143                echo "PO ST failure : local en vironment,  send no n otices"
  144           }
  145           el se{
  146                      ec ho "POST F ailure: Ch eck-in and  deliver f ailed"
  147              //echo "PO ST failure : send ema il notific ation"
  148              //notifyBu ildStatus( currentBui ld.result)
  149           }
  150         }
  151         echo  "POST fai lure: coll ecting con sole log"
  152         getC onsoleLog( )
  153         arch iveArtifac ts allowEm ptyArchive : true, ar tifacts: ' **/*.log,  *.html, *. tar.gz, e2 e_testresu lts.xml' ,  onlyIfSuc cessful: f alse
  154         echo  'POST fai lure: Perf orming cle anup tasks  for build  failure'
  155         dele teDir()
  156       }
  157     }
  158   }
  159   // RTC ste ps for che ckin and d eliver
  160   def rtcChe ckin(){
  161     withCred entials([u sernamePas sword(cred entialsId:  'RTC_BUIL D', userna meVariable : 'rtcUser ', passwor dVariable:  'rtcPass' )]) {
  162     // avail able as an  env varia ble, but w ill be mas ked if you  try to pr int it out  any which  way
  163       def MY HOSTNAME=g etHostname ()
  164       def la stBuildDat e=new Date (currentBu ild.startT imeInMilli s).format( 'MMM dd, y yyy HH:mm: ss Z')
  165       def ve rsionStrin g="version : ${packag eVersion}"
  166       def bu ildDateStr ing="lastB uildDate:  ${lastBuil dDate}"
  167       def di stribution String="di stribution FileName:  <staging_u rl>/${DIST _OUTPUT_FI LENAME}"
  168       def co mmitCommen t = /"${ve rsionStrin g}, ${buil dDateStrin g}, ${dist ributionSt ring},jenk ins-${JOB_ BASE_NAME} -${BUILD_N UMBER}-${M YHOSTNAME} "/
  169       def wo rkitem = " ${RTC_WORK ITEM}"
  170       def co mponents=  ["${TAS_IN FRA}"]
  171  
  172       echo " show scm s tatus"
  173       sh """
  174         ${sc mtool} sho w status - u ${rtcUse r} -P ${rt cPass} -v  --all -d $ {TASWorksp ace}
  175         echo  "----- -- --- -----  ----- ---- -"
  176       """
  177       
  178       echo " prepare to  checkin c omponents"
  179       for (c omponent i n componen ts){
  180         echo  "loop thr ough each  file in $c omponent"
  181         sh " ""
  182           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}/{} \ \;
  183         """
  184         echo  "${scmtoo l} checkin  $componen t/*"
  185         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/*"
  186         echo  "----- -- --- -----  ----- ---- -"
  187       }
  188       // the  following  is not va lid until  rtc 6.0.4
  189       //step ([$class:  'RTCPostBu ildDeliver Publisher' , failOnEr ror: true] )
  190     }
  191   }
  192  
  193   def rtcDel iver(){
  194     withCred entials([u sernamePas sword(cred entialsId:  'RTC_BUIL D', userna meVariable : 'rtcUser ', passwor dVariable:  'rtcPass' )]) {
  195     // avail able as an  env varia ble, but w ill be mas ked if you  try to pr int it out  any which  way
  196       def wo rkitem = " ${RTC_WORK ITEM}"
  197       echo " show scm s tatus"
  198       sh """
  199         ${sc mtool} sho w status - u ${rtcUse r} -P ${rt cPass} -v  --all -d $ {TASWorksp ace}
  200         echo  "----- -- --- -----  ----- ---- -"
  201       """
  202       echo " RTC ${rtcU ser} deliv er "
  203       def de liverStatu s=sh (
  204       script : "${scmto ol} delive r -u ${rtc User} -P $ {rtcPass}  -v",
  205       return Status: tr ue
  206       )
  207       if (de liverStatu s == 0 ||  deliverSta tus == 52  || deliver Status ==  53){
  208         echo  "Deliver  succeed"
  209         retu rn 0
  210       }
  211       else {
  212         curr entBuild.r esult='FAI LED'
  213         erro r("FAIL: S CM deliver  failed wi th ${deliv erStatus}" )
  214       }
  215       // the  following  is not va lid until  rtc 6.0.4
  216       //step ([$class:  'RTCPostBu ildDeliver Publisher' , failOnEr ror: true] )
  217     }
  218   }
  219  
  220   def rtcBas eline(){
  221     withCred entials([u sernamePas sword(cred entialsId:  'RTC_BUIL D', userna meVariable : 'rtcUser ', passwor dVariable:  'rtcPass' )]) {
  222     // avail able as an  env varia ble, but w ill be mas ked if you  try to pr int it out  any which  way
  223       echo " RTC list w orkspaces  "
  224       def wo rkspaceLis t=sh (
  225       script : "${scmto ol} list w orkspaces  -r local - v",
  226       return Stdout: tr ue
  227       ).trim ()
  228  
  229       echo " workspace:  ${workspa ceList}"
  230  
  231       echo " RTC ${rtcU ser} creat e baseline  "
  232       sh """
  233         ${sc mtool} cre ate baseli ne -u ${rt cUser} -P  ${rtcPass}  --all ${w orkspaceLi st} ${pack ageVersion
  234       """
  235       // the  following  is not va lid until  rtc 6.0.4
  236       //step ([$class:  'RTCPostBu ildDeliver Publisher' , failOnEr ror: true] )
  237     }
  238   }
  239  
  240   def getBra nchName(){
  241     def bran ch="${GIT_ BRANCH}"
  242     return b ranch.toke nize('/')[ 1].toLower Case()
  243   }
  244   // load wo rkspace
  245   def getHal fakerCode( ){
  246     branch_n ame=getBra nchName()
  247     echo "($ {branch_na me}), [${G IT_BRANCH} ]"
  248     echo "ge t the code "
  249     sh """
  250       git co nfig --glo bal core.a utocrlf fa lse
  251       git co nfig --glo bal creden tial.helpe r 'cache - -timeout=3 600'
  252     """
  253     git cred entialsId:  'jenkins_ build', ur l: "${mccf _git_repo} ", poll: f alse, bran ch: "${bra nch_name}"
  254     echo ("g et last gi t tag")
  255     lastGitT ag=gitDesc ribe()
  256     def last Commit=get LastGitCom mit()
  257     echo ("c heck lastG itTag (${l astGitTag} )")
  258     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")
  259     if ( las tGitTag?.t rim() ){
  260       echo ( "Ready to  build ${la stGitTag}  (${lastCom mit})")
  261     }
  262     else {
  263       error( "FAIL: no  source pul led from $ {mccf_git_ repo}")
  264     }
  265    }
  266  
  267    // git fu nctions
  268   def getCha ngesets(){
  269       def ch angeLogSet s = curren tBuild.cha ngeSets
  270       echo " reviewing  changesets :"
  271       def co mmitMessag e=""
  272       for (i nt i = 0;  i < change LogSets.si ze(); i++)  {
  273           de f entries  = changeLo gSets[i].i tems
  274           fo r (int j =  0; j < en tries.leng th; j++) {
  275                def entr y = entrie s[j]
  276                commitMe ssage="${c ommitMessa ge} \n ${e ntry.commi tId} by ${ entry.auth or} on ${n ew Date(en try.timest amp)}"
  277                echo "${ entry.comm itId} by $ {entry.aut hor} on ${ new Date(e ntry.times tamp)}: ${ entry.msg} "
  278                def file s = new Ar rayList(en try.affect edFiles)
  279                for (int  k = 0; k  < files.si ze(); k++)  {
  280                    def  file = fil es[k]
  281                    echo  "  ${file .editType. name} ${fi le.path}"
  282                }
  283           }
  284       }
  285       return  "${commit Message}"
  286   }
  287  
  288   def gitDes cribe(){
  289     echo "ge tting last  git tag"
  290     def MYIN FO
  291     def tagE xists=sh(r eturnStdou t: true, s cript: 'gi t tag --li st').trim( )
  292     if ( tag Exists?.tr im() ) {
  293       MYINFO =sh(return Stdout: tr ue, script : 'git des cribe').tr im()
  294     }
  295     else {
  296       MYINFO =sh(return Stdout: tr ue, script : 'git des cribe --al ways').tri m()
  297     }
  298     echo ("w e need to  parse ${MY INFO} to d etermine i f the late st tag is  the latest  commit")
  299     MYINFO
  300   }
  301  
  302   def getLas tGitCommit (){
  303     echo "ge tting last  git commi t"
  304     def LAST _COMMIT
  305     LAST_COM MIT = sh (
  306       script : 'git rev -parse HEA D',
  307       return Stdout: tr ue
  308     ).trim()
  309     echo ("t he last co mmit is ${ LAST_COMMI T[0..6]}")
  310     LAST_COM MIT[0..6]
  311   }
  312  
  313   def gitTag Build(){
  314     withCred entials([u sernamePas sword(cred entialsId:  'jenkins_ build', pa sswordVari able: 'jen kinsPass',  usernameV ariable: ' jenkinsUse r')]) {
  315       def MY HOSTNAME=g etHostname ()
  316       def co mmit_messa ge = /"jen kins-${JOB _BASE_NAME }-${BUILD_ NUMBER}-${ MYHOSTNAME }"/
  317       sh 'gi t config - -list'
  318       echo " set the us er.name, u ser.email"
  319       def uE mail = /"m ccfsystema dmins@half aker.com"/  
  320       sh """
  321         git  config use r.name "${ jenkinsUse r}"
  322         git  config use r.email ${ uEmail}
  323         git  config --g lobal push .default s imple
  324         git  config ali as.version log "notes  --ref=ver sionlog ap pend"
  325         git  config --a dd remote. origin.pus h '+refs/n otes/*:ref s/notes/*'
  326         git  config --a dd remote. origin.fet ch '+refs/ notes/*:re fs/notes/* '
  327         git  remote set -url origi n ${GIT_UR L}
  328         git  config --l ist 
  329       """
  330       echo " append ver sion note  to this co mmit"
  331       addGit VersionLog ()
  332       echo " tag this c ommit"
  333       sh """
  334         git  tag -a ${p ackageVers ion} -m '$ {commit_me ssage}' ${ lastCommit ID}
  335         echo  "push cha nges to re mote"
  336         git  push origi n --tags - -verbose
  337       """
  338     }
  339   }
  340  
  341   def addGit VersionLog (){
  342     def last BuildDate= new Date(c urrentBuil d.startTim eInMillis) .format('M MM dd, yyy y HH:mm:ss  Z')
  343     def vers ionString= "version:  ${packageV ersion}"
  344     def buil dDateStrin g="lastBui ldDate: ${ lastBuildD ate}"
  345     def dist ributionSt ring="dist ributionFi leName: <s taging_url >/${DIST_O UTPUT_FILE NAME}"
  346     sh """
  347       git ve rsionlog $ {lastCommi tID} -m "$ {versionSt ring}, ${b uildDateSt ring}, ${d istributio nString}"
  348     """
  349   }
  350  
  351   // helper  functions
  352   def getHos tname(){
  353     def THIS HOSTNAME
  354     if(isUni x()){
  355       THISHO STNAME = s h (
  356         scri pt: 'hostn ame',
  357         retu rnStdout:  true
  358       ).trim ()
  359     }
  360     else {
  361       THISHO STNAME = b at (
  362         scri pt: 'hostn ame',
  363         retu rnStdout:  true
  364       ).trim ()
  365     }
  366     THISHOST NAME
  367   }
  368  
  369   def getPac kageName() {
  370     echo "ge tting pack age name"
  371     def MYNA ME
  372     MYNAME =  sh (
  373         scri pt: 'npm r un env | g rep npm_pa ckage_name  | cut -d  \"=\" -f 2 ',
  374         retu rnStdout:  true
  375       ).trim ()
  376     MYNAME
  377   }
  378  
  379   def update IndexMetaD ata(){
  380     def last BuildDate= new Date(c urrentBuil d.startTim eInMillis) .format('M MM dd, yyy y HH:mm:ss  Z')
  381     def meta Data=["dis tributionF ileName":" ${DIST_OUT PUT_FILENA ME}", "las tBuildDate ":"${lastB uildDate}" , "version ":"${packa geVersion} " ]
  382     echo 'ba ckup the i ndex file  before edi ting'
  383     sh "cp $ {index} ${ index}.bak "
  384     for (kv  in mapToLi st(metaDat a)){
  385        def n ame=kv[0]
  386        def c ontent=kv[ 1]
  387        echo  "update me ta tag nam e=\"${name }\", conte nt=\"${con tent}\""
  388        sh "" "
  389          sed  -Ei '/<he ad.*?>/a < meta name= \"${name}\ " content= \"${conten t}\" >' "$ {index}"
  390          if  grep -i '< meta name= \"${name}\ " content= \"${conten t}\" >' "$ {index}"
  391          the n
  392            e cho "PROCE ED: added  meta tag f or ${name} "
  393          els e
  394            e cho "FAILE D: unable  to find ta g for ${na me}"
  395            e xit 1
  396          fi
  397        """
  398     }
  399   }
  400  
  401   def checkN pmInstallL og(log){
  402     echo "ch ecking npm  install l og for 'Do wnloading. *github'"
  403     def MYRE SULT
  404     MYRESULT  = sh (
  405         scri pt: """
  406           if  grep -Exi q -e "Down loading.*g ithub" ${l og}
  407           th en
  408              echo "FAIL ED: unauth orized dow nload"
  409           el if grep -E xiq -e "HT TP error 4 04 not Fou nd" ${log}
  410           th en
  411              echo "FAIL ED: HTTP e rror 404 n ot Found"
  412           el se
  413              echo "PROC EED: Nothi ng incrimi nating fou nd in log"
  414           fi
  415           "" ",
  416         retu rnStdout:  true
  417       ).trim ()
  418     return M YRESULT
  419   }
  420  
  421   def checkD ependencie sLog(log){
  422     echo "ch ecking  lo g for 'not  installed '"
  423     def MYRE SULT
  424     MYRESULT  = sh (
  425         scri pt: """
  426           if  grep -Exq  ".*not in stalled.*"  ${log}
  427           th en
  428              echo "FAIL ED: packag es not ins talled"
  429           el se
  430              echo "PROC EED: All p ackages in stalled"
  431           fi
  432           "" ",
  433         retu rnStdout:  true
  434       ).trim ()
  435     return M YRESULT
  436   }
  437  
  438   def stageL atestArtif act(artifa ct){
  439       echo " stage the  latest bui ld artifac t(${artifa ct}) for d eployment"
  440       def ar tifact_nam e= artifac t.tokenize ('/').last ()
  441       def st aging = ST AGING_DIR. trim().toL owerCase()
  442       def la test = "${ WEB_BASEDI R}/latest_ dev"
  443       echo " check for  TGT_STREAM "
  444       if(env .branch_na me && env. branch_nam e?.trim(). toLowerCas e() != 'ma ster'){
  445         echo  "staging  for branch  build (${ branch_nam e})"
  446         def  link=branc h_name?.tr im().toLow erCase()
  447         late st = "${WE B_BASEDIR} /latest_${ link}"
  448       }
  449       else{
  450         if(e nv.TGT_STR EAM && env .TGT_STREA M?.trim()) {
  451           ec ho "TGT_ST REAM found  (${TGT_ST REAM})"
  452           de f link=TGT _STREAM.tr im().toLow erCase()
  453           la test = "${ WEB_BASEDI R}/latest_ ${link}"
  454         }
  455       }
  456       try {
  457           ec ho "check  ${staging}  directory  exist"
  458           sh  "[[ -d ${ staging} ] ] || sudo  mkdir -p $ {staging}"
  459           ec ho "fix di rectory pe rmissions"
  460           sh  """
  461              set -x
  462              sudo find  \$(dirname  ${STAGING _DIR}) -ty pe d -exec  chmod 075 5 {} \\;
  463           "" "
  464           ec ho "copy $ {artifact}  to ${stag ing}/"
  465           sh  "sudo cp  ${artifact } ${stagin g}/"
  466           ec ho "create  symbolic  link to st aged artif act"
  467           sh  "sudo ln  -sfn ${sta ging}/${ar tifact_nam e} ${lates t}"
  468           ec ho "verify  link crea ted"
  469           de f linkExis ts=sh (
  470                script:  "readlink  ${latest}" ,
  471                returnSt dout: true
  472                ).trim()
  473           sh  """
  474                if [[ -n  "${linkEx ists}" ]];  then
  475                    echo  "link exi sts for ${ latest}"
  476                else
  477                    echo  "link not  found ${l atest}"
  478                fi
  479           "" "
  480       } catc h(Exceptio n e){
  481           ec ho "someth ing bad ha ppened whi le staging  artifact,  throw and  fail"
  482           ec ho e.toStr ing()
  483           th row e
  484       }
  485   }
  486   // notifyH ipchat
  487   // will se nd color c oded notif ications t o hipchat
  488   //
  489   def notify Hipchat(St ring build Status = ' STARTED',  String hcR oom = '324 2078') {
  490   // build s tatus of n ull means  successful
  491     buildSta tus =  bui ldStatus ? : 'SUCCESS FUL'
  492  
  493     def last Build = cu rrentBuild .getPrevio usBuild()
  494  
  495     // Defau lt values
  496     def colo r = 'RED'
  497     def colo rCode = '# FF0000'
  498     def subj ect = "${b uildStatus }: Job '${ env.JOB_NA ME} [${env .BUILD_NUM BER}]'"
  499     def summ ary = "${s ubject} ($ {env.BUILD _URL})"
  500  
  501       // Ove rride defa ult values  based on  build stat us
  502     if (buil dStatus ==  'STARTED' ) {
  503       color  = 'YELLOW'
  504       colorC ode = '#FF FF00'
  505     } 
  506     else if  (buildStat us == 'SUC CESSFUL')  {
  507       color  = 'GREEN'
  508       colorC ode = '#00 FF00'
  509       if( la stBuild &&  lastBuild .getResult ().toStrin g()=="FAIL URE" ){
  510         buil dStatus =  'FIXED'
  511       }
  512     } 
  513     else if  (buildStat us == 'ABO RTED') {
  514       color  = 'PURPLE'
  515       colorC ode = '#80 0080'
  516     }
  517     else if  (buildStat us == 'UNS TABLE') {
  518       color  = 'GRAY'
  519       colorC ode = '#80 8080'
  520     }
  521     else {
  522       color  = 'RED'
  523       colorC ode = '#FF 0000'
  524     }
  525    
  526      // Send  notificat ions
  527     echo "se nd notice  of ${build Status} to  hipchat r oom: ${hcR oom}"
  528     def hcMe ssage=getC hangesets( )
  529     if(build Status ==  'SUCCESSFU L'){
  530       echo " only send  notice if  previous b uild faile d"
  531       if( la stBuild &&  lastBuild .getResult ().toStrin g()=="FAIL URE" ){
  532         echo  "the prev ious build  ${lastBui ld.getId() } failed,  send updat e"
  533         hipc hatSend (
  534           co lor: color
  535           cr edentialId : 'jenkins _hc_notifi cation', 
  536           me ssage: sum mary + ":  changesets :  " + hcM essage, 
  537           no tify: true
  538           ro om: hcRoom
  539           se ndAs: 'jen kins_build ', 
  540           te xtFormat:  false, 
  541           v2 enabled: t rue
  542         )
  543       }
  544       else {
  545         echo  "the prev ious build  " + lastB uild.getRe sult().toS tring()
  546       }
  547     }
  548     else {
  549       echo " this build  ${buildSt atus}"
  550       hipcha tSend (
  551         colo r: color,
  552         cred entialId:  'jenkins_h c_notifica tion',
  553         mess age: summa ry + ": ch angesets:   " + hcMes sage,
  554         noti fy: true,
  555         room : hcRoom,
  556         send As: 'jenki ns_build',
  557         text Format: fa lse,
  558         v2en abled: tru e
  559       )
  560     }
  561   }
  562  
  563   def notify BuildStatu s(String b uildStatus  = 'STARTE D') {
  564     // build  status of  null mean s successf ul
  565     buildSta tus =  bui ldStatus ? : 'SUCCESS FUL'
  566  
  567   //recipien tProviders  (optional )
  568   //$class:  CulpritsRe cipientPro vider
  569   //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.
  570   //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  
  571   //was a fa ilure it a lso includ es the cul prit list  from there .
  572  
  573   //$class:  Developers RecipientP rovider
  574   //Sends em ail to all  the peopl e who caus ed a chang e in the c hange set.
  575  
  576   //$class:  FailingTes tSuspectsR ecipientPr ovider
  577   //Sends em ail to the  list of u sers suspe cted of ca using a un it test to  begin fai ling.
  578   //This lis t includes  committer s and requ estors of  the build  where the  test began  to fail,
  579   //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.
  580  
  581   //$class:  FirstFaili ngBuildSus pectsRecip ientProvid er
  582   //Sends em ail to the  list of u sers suspe cted of ca using the  build to b egin faili ng.
  583  
  584   //$class:  ListRecipi entProvide r
  585   //Sends em ail to the  list of r ecipients  defined in  the "Proj ect Recipi ent List."
  586  
  587   //$class:  RequesterR ecipientPr ovider
  588   //Sends em ail to the  user who  initiated  the build.
  589  
  590   //$class:  UpstreamCo mitterReci pientProvi der
  591   //Sends em ail to the  list of u sers who c ommitted c hanges in  upstream b uilds that  triggered  this buil d
  592   // Default  values            Li stRecipien tProvider
  593     def reci pients=[[$ class: 'Li stRecipien tProvider' ]]
  594     def subj ect = "${b uildStatus }: Job '${ env.JOB_NA ME} [${env .BUILD_NUM BER}]'"
  595     def repl yto = "${e nv.DEFAULT _REPLYTO}"
  596     def mime Type = "te xt/html"
  597     def send to = "${en v.DEFAULT_ RECIPIENTS }"
  598     def deta ils = """
  599       <p>Job : '${env.J OB_NAME} b uild: [${e nv.BUILD_N UMBER}]':< /p>
  600       <p>Che ck console  output at  "<a href= "${env.BUI LD_URL}">$ {env.JOB_N AME} [${en v.BUILD_NU MBER}]</a> "</p>
  601       """
  602  
  603       // Ove rride defa ult values  based on  build stat us
  604     if (buil dStatus ==  'STARTED'  || buildS tatus == ' SUCCESSFUL ' || build Status ==  'FIXED') {
  605       recipi ents = [[$ class: 'De velopersRe cipientPro vider']]
  606     } 
  607    
  608     else if  (buildStat us == 'ABO RTED' || b uildStatus  == 'UNSTA BLE') {
  609       recipi ents = [[$ class: 'De velopersRe cipientPro vider']]
  610     }
  611     else {
  612       echo " unknown st atus"
  613       recipi ents = [[$ class: 'Cu lpritsReci pientProvi der'], [$c lass: 'Req uesterReci pientProvi der']]
  614     }
  615   //examples
  616   //Notify C ulprits an d Requeste r via defa ult EMail  plugin
  617   //step([$c lass: 'Mai ler', noti fyEveryUns tableBuild : true, re cipients:  emailextre cipients([ [$class: ' CulpritsRe cipientPro vider'], [ $class: 'R equesterRe cipientPro vider']])] )
  618  
  619   //Send an  email to a bc plus an y addresse s returned  by the pr oviders
  620   //emailext  body: 'A  Test EMail ', 
  621   //          recipient Providers:  [[$class:  'Develope rsRecipien tProvider' ], [$class : 'Request erRecipien tProvider' ]], 
  622   //          subject:  'Test', 
  623   //          to: 'abc'
  624     echo "se nd email t o recipien ts (${reci pients}) f or ${build Status}"
  625     echo """
  626         subj ect: ${sub ject},
  627         body : ${detail s},
  628         reci pientProvi ders: ${re cipients},
  629         repl yTo: ${rep lyto},
  630         to:  ${sendto}
  631         """
  632     mail (
  633         body : details,  
  634         cc:  ' PII ', 
  635         mime Type: 'tex t/html', 
  636         repl yTo: reply to, 
  637         subj ect: subje ct, 
  638         to:  sendto
  639         )
  640   }
  641  
  642   //save log  to worksp ace
  643   def getCon soleLog(){
  644     echo "ge tConsoleLo g: prepare  logfilena me to get  console lo g"
  645     def logF ilename="$ {JOB_URL}"
  646     def work spaceLog=" ${WORKSPAC E}/${JOB_B ASE_NAME}_ ${BUILD_NU MBER}_cons ole.log"
  647     echo "ge tConsoleLo g: console  log is ${ logFilenam e} (same a s job url) "
  648     logFilen ame=logFil ename.trim ().replace ("${JENKIN S_URL}","$ {JENKINS_H OME}/")
  649     echo "ge tConsoleLo g: console  log is ch anged to $ {logFilena me}"
  650     logFilen ame=logFil ename.trim ().replace All("job", "jobs")
  651     echo "ge tConsoleLo g: console  log is ch anged agai n to ${log Filename}"
  652     logFilen ame="${log Filename}b uilds/${BU ILD_NUMBER }/log"
  653     echo "ge tConsoleLo g: console  log is fi nally  ${l ogFilename }"
  654     echo "ge tConsoleLo g: prepare  to write  to ${works paceLog}"
  655     sh """
  656       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"
  657       sed -e  "s,\\x1b\ \[3[0-9][m GKA],,gm;s ,\\x1b\\[1 A,,gm;s,\\ x1b\\[2K,, gm;" "tmp. log" > "${ workspaceL og}"
  658       rm "tm p.log"
  659       echo " getConsole Log: verif y ${worksp aceLog} re ady for ar chival"
  660       if [[  -f "${work spaceLog}"  ]]
  661       then
  662         echo  "getConso leLog: loc al console  log (${wo rkspaceLog }) exists,  safe to p roceed"
  663       else
  664         echo  "getConso leLog: No  local cons ole log ($ {workspace Log}) foun d"
  665       fi
  666     """
  667   }
  668   // Require d due to J ENKINS-274 21
  669   @NonCPS
  670   List<List< ?>> mapToL ist(Map ma p) {
  671     return m ap.collect  { it ->
  672       [it.ke y, it.valu e]
  673     }
  674   }
  675