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

315.1 Files compared

# Location File Last Modified
1 MCCF_EDI_TAS_TASCore v2.0_Build_10.zip\MCCF_EDI_TAS_DevOps\mccf_devops createCentos.jenkinsfile Wed Apr 3 02:27:32 2019 UTC
2 MCCF_EDI_TAS_TASCore v2.0_Build_10.zip\MCCF_EDI_TAS_DevOps\mccf_devops createCentos.jenkinsfile Tue Apr 16 15:27:26 2019 UTC

315.2 Comparison summary

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

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

315.4 Active regular expressions

No regular expressions were active.

315.5 Comparison detail

  1   pipeline()  {
  2     environm ent{
  3       def EN VIRON = "$ {ENV}"
  4       def pr oductAcron ym="CentOS 7"
  5       def pr oductMajor Version='0 1'
  6       def pr oductMinor Version='0 0'
  7       def pr oductRev=" ${BUILD_NU MBER}"
  8       def pa ckageVersi on="${prod uctAcronym }.${produc tMajorVers ion}.${pro ductMinorV ersion}.${ productRev }"
  9       def hc Room = '32 42078'
  10       def da teString =  new Date( currentBui ld.startTi meInMillis ).format(' yyyyMMdd_H Hmmss')
  11       def AR TIFACT_LOC ATION = "$ {WORKSPACE }/artifact s/${dateSt ring}"
  12       def DI ST_OUTPUT_ FILENAME=' '
  13       def DI ST_OUTPUT_ FILE=''
  14       def la stCommitID =''
  15       def pa ckageName= ''
  16       def WE B_BASEDIR= "/var/www/ html"
  17       def ST AGING_DIR= "${WEB_BAS EDIR}/dev/ repo/docke rimages"
  18       def mc cf_git_rep o="https:/ /bitbucket .org/halfa ker/mccf_d evops"
  19       def bu ildResultU UID=''
  20       def TA SWorkspace ="${WORKSP ACE}"
  21       def RT C_TAS_DEVO PS="${WORK SPACE}/MCC F_EDI_TAS_ Infrastruc ture/mccf_ devops"
  22       def RT C_BUILD_AR TIFACTS="B uild_Artif acts"
  23       def la stGitTag=' '
  24       def sc mtool="/op t/ibm/team concert/6. 0.1/jazz/s cmtools/ec lipse/scm. sh"
  25       def lo calTMP="${ WORKSPACE} /tmp"
  26       def ce ntosTAG="c entos7:cen tos7"
  27     }
  28     agent an y
  29     options  { timestam ps() } 
  30     stages{
  31       stage( 'Prepare w orkspace w ith source  code') {
  32         step s{
  33           sc ript{
  34              def bldENV =ENV?.trim ().toUpper Case()
  35              echo "dete rmine regi on for ${b ldENV}"
  36              def region =bldENV[0. .2]
  37              echo "dete rmine main  env for r egion ${re gion}, (ak a ${bldENV })"
  38              def mainEN V=bldENV[- 3..-1]
  39              echo "dete rmine acti on for ${b ldENV}, (a ka ${regio n}, ${main ENV})"
  40              switch(reg ion){
  41                case "AW S":
  42                  echo " AWS enviro nment, Pre pare Halfa ker worksp ace"
  43                  dir("$ {TASWorksp ace}"){
  44                    getH alfakerCod e()
  45                  }
  46                  break
  47                case "ED E":
  48                case "MA G":
  49                  echo ( "Initializ e workspac e from RTC ")
  50                  if (!T GT_STREAM? .trim().to UpperCase( ).equals(" DEV")){
  51                    STAG ING_DIR="$ {WEB_BASED IR}/rtc/ta s"
  52                  }
  53                  teamco ncert([
  54                    buil dType: [
  55                      bu ildDefinit ion: "${bu ildDefinit ionId}",
  56                      va lue: 'buil dDefinitio n'
  57                    ]
  58                  ])
  59                  echo ( "Verify co mponent ($ {TASWorksp ace}) exis ts")
  60                  sh '''
  61                    if [ [ -d "${TA SWorkspace }" ]]
  62                    then
  63                      ec ho "Compon ent (${TAS Workspace} ) exists,  safe to pr oceed"
  64                    else
  65                      fa il "FAIL:  No compone nt (${TASW orkspace})  found"
  66                    fi
  67                  '''
  68                  echo " EDE enviro nment, det ermine SRC _STREAM"
  69                  if(mai nENV.equal s("DEV") & &  SRC_STR EAM?.trim( ).toUpperC ase().equa ls("HAF")) {
  70                    echo  "need to  get HAF co de"
  71                    dir( "${localTM P}"){
  72                      ge tHalfakerC ode()
  73                      ec ho "need t o check la stGitCommi t against  lastGitTag "
  74                    }
  75                    dir( "${TASWork space}"){
  76                      sh  'cp -p .p roject ../ taswebui.p roject'
  77                      sh  'rsync -a cvWh "${lo calTMP}/"  . --exclud e ".git" - -del'
  78                      sh  'mv ../ta swebui.pro ject .proj ect'
  79                    }
  80                  }
  81                  break
  82                default:
  83                  echo " local envi ronment, P repare Hal faker work space"
  84                  sh 'pr intenv'
  85                  dir("$ {TASWorksp ace}"){
  86                    getH alfakerCod e()
  87                  }
  88              }
  89           }
  90         }
  91       }
  92       stage( 'Pre-Build  Setup'){
  93         step s{
  94           ec ho "set fi nal packag eVersion"
  95           di r("${TASWo rkspace}") {
  96              script{
  97                if(ENV?. trim().toU pperCase() .startsWit h("EDE") | | ENV?.tri m().toUppe rCase().st artsWith(" MAG")){
  98                  echo " building i n EDE, do  not use gi t commit i n packageV ersion"
  99                  packag eVersion=" ${packageV ersion}_${ dateString }"
  100                }
  101                else {
  102                  echo " git build"
  103                  lastCo mmitID=get LastGitCom mit()
  104                  echo " last commi t is ${las tCommitID} "
  105                  if(las tCommitID? .trim()){
  106                      pa ckageVersi on="${pack ageVersion }_${lastCo mmitID}"
  107                  }
  108                }
  109                echo "fi nal packag eVersion f or tag ${p ackageVers ion}"
  110                DIST_OUT PUT_FILENA ME="${pack ageVersion }.tar.gz"
  111                echo "bu ilding for  package $ {DIST_OUTP UT_FILENAM E}"
  112              }
  113           }
  114         }
  115       }
  116       stage( 'Create Ce ntOS Docke r Image TA R file'){
  117         step s{
  118           di r("${TASWo rkspace}/s cripts/she ll"){
  119              script{
  120                sh """
  121                    echo  "Fix perm issions fo r script"
  122                    sudo  chmod 755  ./createM CCFCentOSB aseDockerI mage.sh
  123                    sudo  ./createM CCFCentOSB aseDockerI mage.sh -r  ${MCCF_RE PO} -o ${T ASWorkspac e} ${DIST_ OUTPUT_FIL ENAME}
  124                """
  125                if (file Exists("${ TASWorkspa ce}/${DIST _OUTPUT_FI LENAME}"))  {
  126                  echo " ${TASWorks pace}/${DI ST_OUTPUT_ FILENAME}  created"
  127                } 
  128                else {
  129                  error( "FAIL: ${T ASWorkspac e}/${DIST_ OUTPUT_FIL ENAME} not  created")
  130                } 
  131              }
  132           }
  133         }
  134       }
  135       stage( 'Import an d Verify C entOS Dock er Image')  {
  136         step s{
  137           ec ho "Import  package $ {DIST_OUTP UT_FILENAM E}"
  138           di r ("${TASW orkspace}" ){
  139              sh "sudo d ocker impo rt ${DIST_ OUTPUT_FIL ENAME} ${c entosTAG}"
  140              echo "Veri fy CentOS  Docker Ima ge Importe d Successf ully"
  141              getInspect ionStatus( )
  142           }
  143         }
  144       }
  145       stage( 'Stage Pac kage') {
  146         step s{
  147           ec ho "Stage  the packag ed distrib ution (${D IST_OUTPUT _FILENAME} ) for ${pa ckageVersi on}"
  148           st ageLatestA rtifact("$ {DIST_OUTP UT_FILENAM E}")
  149         }
  150       }
  151     }
  152     post{
  153       always {
  154         sh " sudo docke r rmi -f \ $(sudo doc ker images  -q)"
  155         echo  "POST alw ays: all t asks are c ompleted,  collecting  environme nt variabl es to ${WO RKSPACE}/$ {BUILD_TAG }.log"
  156         sh ' printenv > > $WORKSPA CE/$BUILD_ TAG.log'
  157         echo  "POST alw ays: archi ving all l ogs and ar tifacts sp ecified"
  158         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: '']
  159       }
  160       succes s{
  161         echo  'POST suc cess: chec k environm ent to det ermine com mit action s'
  162         scri pt {
  163           de f myENV="$ {ENV}"
  164           de f subENV=m yENV[0..2]
  165           de f EDE_ARTI FACT_LOCAT ION = "${W ORKSPACE}/ ${RTC_BUIL D_ARTIFACT S}/${packa geVersion} "
  166           ec ho "POST s uccess: de termine pr oper commi t action f or ${myENV }, (aka ${ subENV})"
  167           sw itch(subEN V.toUpperC ase()){
  168              case "AWS" :
  169                echo "PO ST success : AWS envi ronment, u se git to  tag this b uild"
  170                gitTagBu ild()
  171                echo "PO ST success : in AWS,  make hipch at notific ation"
  172                notifyHi pchat(curr entBuild.r esult,hcRo om)
  173                break
  174              case "EDE" :
  175              case "MAG" :
  176                echo "PO ST success : copy pac kaged arti fact (${DI ST_OUTPUT_ FILE}) to  ${RTC_BUIL D_ARTIFACT S}"
  177                sh """
  178                  mkdir  -p "${EDE_ ARTIFACT_L OCATION}"
  179                  cp "${ DIST_OUTPU T_FILE}" " ${EDE_ARTI FACT_LOCAT ION}/"
  180                  echo " POST succe ss: check  ${EDE_ARTI FACT_LOCAT ION}/${DIS T_OUTPUT_F ILENAME}"
  181                  if [[  -f "${EDE_ ARTIFACT_L OCATION}/$ {DIST_OUTP UT_FILENAM E}" ]]
  182                  then
  183                    echo  "POST suc cess: Arti fact (${ED E_ARTIFACT _LOCATION} /${DIST_OU TPUT_FILEN AME}) exis ts, safe t o proceed"
  184                  else
  185                    fail  "FAIL: PO ST success : No artif act (${EDE _ARTIFACT_ LOCATION}/ ${DIST_OUT PUT_FILENA ME}) found "
  186                  fi
  187                 """
  188                echo "cl eanup prio r to check in and del iver"
  189                dir("${T AS_API}"){
  190                  sh 'rm  -rf node_ modules'
  191                  sh 'rm  -rf e2e/l ogs'
  192                  sh 'rm  -rf dist'
  193                  sh 'fi nd . -name  "*.log" - type f -de lete'
  194                }
  195                rtcCheck in()
  196                rtcDeliv er()
  197                echo "PO ST success : send ema il notific ation"
  198                notifyBu ildStatus( currentBui ld.result)
  199              break
  200              default:
  201               echo "POS T success:  local env ironment,  send no no tices"
  202               echo "POS T success:  local env ironment,  do not com mit any ta g"
  203           }
  204         }
  205         echo  "POST suc cess: coll ecting con sole log"
  206         getC onsoleLog( )
  207         arch iveArtifac ts allowEm ptyArchive : true, ar tifacts: ' **/*.log,  *.html, *. tar.gz, e2 e_testresu lts.xml' ,  onlyIfSuc cessful: f alse
  208         echo  'POST suc cess: Perf orming cle anup tasks  after bui ld success '
  209         dele teDir()
  210       }
  211       failur e{
  212         scri pt{
  213           if (BUILD_URL .toLowerCa se().conta ins("aws") ){
  214              echo "POST  failure:  in AWS, ma ke hipchat  notificat ion"
  215              notifyHipc hat(curren tBuild.res ult,hcRoom )
  216           }
  217           if (ENV.toLow erCase().c ontains("l ocal")){
  218                echo "PO ST failure : local en vironment,  send no n otices"
  219           }
  220           el se{
  221              echo "POST  failure:  send email  notificat ion"
  222              notifyBuil dStatus(cu rrentBuild .result)
  223           }
  224         }
  225         echo  "POST fai lure: coll ecting con sole log"
  226         getC onsoleLog( )
  227         arch iveArtifac ts allowEm ptyArchive : true, ar tifacts: ' **/*.log,  *.tar.gz,  *.tar, e2e _testresul ts.xml' ,  onlyIfSucc essful: fa lse
  228         echo  'POST fai lure: Perf orming cle anup tasks  for build  failure'
  229         dele teDir()
  230       }
  231     }
  232   }
  233  
  234   // load wo rkspace
  235   def getHal fakerCode( ){
  236     sh """
  237       echo " cache cred entials 'c ache --tim eout 3600' "
  238       git co nfig --glo bal creden tial.helpe r 'cache - -timeout 3 600'
  239       git co nfig --glo bal core.a utocrlf fa lse
  240     """
  241     git cred entialsId:  'jenkins_ build', ur l: "${mccf _git_repo} ", poll: f alse
  242     echo ("g et last gi t tag")
  243     lastGitT ag=gitDesc ribe()
  244     def last Commit=get LastGitCom mit()
  245     echo ("c heck lastG itTag (${l astGitTag} )")
  246     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")
  247     if ( las tGitTag?.t rim() ){
  248       echo ( "Ready to  build ${la stGitTag}  (${lastCom mit})")
  249     }
  250     else {
  251       error( "FAIL: no  source pul led from $ {mccf_git_ repo}")
  252     }
  253    }
  254    
  255    // git fu nctions
  256   def getCha ngesets(){
  257       def ch angeLogSet s = curren tBuild.cha ngeSets
  258       echo " reviewing  changesets :"
  259       def co mmitMessag e=""
  260       for (i nt i = 0;  i < change LogSets.si ze(); i++)  {
  261           de f entries  = changeLo gSets[i].i tems
  262           fo r (int j =  0; j < en tries.leng th; j++) {
  263                def entr y = entrie s[j]
  264                commitMe ssage="${c ommitMessa ge} \n ${e ntry.commi tId} by ${ entry.auth or} on ${n ew Date(en try.timest amp)}"
  265                echo "${ entry.comm itId} by $ {entry.aut hor} on ${ new Date(e ntry.times tamp)}: ${ entry.msg} "
  266                def file s = new Ar rayList(en try.affect edFiles)
  267                for (int  k = 0; k  < files.si ze(); k++)  {
  268                    def  file = fil es[k]
  269                    echo  "  ${file .editType. name} ${fi le.path}"
  270                }
  271           }
  272       }
  273       return  "${commit Message}"
  274   }
  275  
  276   def gitDes cribe(){
  277     echo "ge tting last  git tag"
  278     def MYIN FO
  279     def tagE xists=sh(r eturnStdou t: true, s cript: 'gi t tag --li st').trim( )
  280     if ( tag Exists?.tr im() ) {
  281       MYINFO =sh(return Stdout: tr ue, script : 'git des cribe').tr im()
  282     }
  283     else {
  284       MYINFO =sh(return Stdout: tr ue, script : 'git des cribe --al ways').tri m()
  285     }
  286     echo ("w e need to  parse ${MY INFO} to d etermine i f the late st tag is  the latest  commit")
  287     MYINFO
  288   }
  289  
  290   def getLas tGitCommit (){
  291     echo "ge tting last  git commi t"
  292     def LAST _COMMIT
  293     LAST_COM MIT = sh (
  294       script : 'git rev -parse HEA D',
  295       return Stdout: tr ue
  296     ).trim()
  297     echo ("t he last co mmit is ${ LAST_COMMI T[0..6]}")
  298     LAST_COM MIT[0..6]
  299   }
  300  
  301   def gitTag Build(){
  302     withCred entials([u sernamePas sword(cred entialsId:  'jenkins_ build', pa sswordVari able: 'jen kinsPass',  usernameV ariable: ' jenkinsUse r')]) {
  303       def MY HOSTNAME=g etHostname ()
  304       def co mmit_messa ge = /"jen kins-${JOB _BASE_NAME }-${BUILD_ NUMBER}-${ MYHOSTNAME }"/
  305       sh 'gi t config - -list'
  306       echo " set the us er.name, u ser.email"
  307       def uE mail = /"m ccfsystema dmins@half aker.com"/  
  308       sh """
  309         git  config use r.name "${ jenkinsUse r}"
  310         git  config use r.email ${ uEmail}
  311         git  config --g lobal push .default s imple
  312         git  config ali as.version log "notes  --ref=ver sionlog ap pend"
  313         git  config --a dd remote. origin.pus h '+refs/n otes/*:ref s/notes/*'
  314         git  config --a dd remote. origin.fet ch '+refs/ notes/*:re fs/notes/* '
  315         git  remote set -url origi n ${GIT_UR L}
  316         git  config --l ist 
  317       """
  318       echo " append ver sion note  to this co mmit"
  319       addGit VersionLog ()
  320       echo " tag this c ommit"
  321       sh """
  322         git  tag -a ${p ackageVers ion} -m '$ {commit_me ssage}' ${ lastCommit ID}
  323         echo  "push cha nges to re mote"
  324         git  push origi n --tags - -verbose
  325       """
  326     }
  327   }
  328  
  329   def addGit VersionLog (){
  330     def last BuildDate= new Date(c urrentBuil d.startTim eInMillis) .format('M MM dd, yyy y HH:mm:ss  Z')
  331     def vers ionString= "version:  ${packageV ersion}"
  332     def buil dDateStrin g="lastBui ldDate: ${ lastBuildD ate}"
  333     def dist ributionSt ring="dist ributionFi leName: <s taging_url >/${DIST_O UTPUT_FILE NAME}"
  334     sh """
  335       git ve rsionlog $ {lastCommi tID} -m "$ {versionSt ring}, ${b uildDateSt ring}, ${d istributio nString}"
  336     """
  337   }
  338  
  339   // helper  functions
  340   def getHos tname(){
  341     def THIS HOSTNAME
  342     if(isUni x()){
  343       THISHO STNAME = s h (
  344         scri pt: 'hostn ame',
  345         retu rnStdout:  true
  346       ).trim ()
  347     }
  348     else {
  349       THISHO STNAME = b at (
  350         scri pt: 'hostn ame',
  351         retu rnStdout:  true
  352       ).trim ()
  353     }
  354     THISHOST NAME
  355   }
  356    
  357   // get doc ker image  inspect st atus
  358   def getIns pectionSta tus(){
  359     def insp ectionStat us=sh (
  360     script:  "sudo dock er image i nspect ${c entosTAG}" ,
  361     returnSt atus: true
  362     )
  363     if (insp ectionStat us == 0){
  364       echo " CentOS Doc ker Image  Imported S uccessfull y"
  365       return  0
  366       } 
  367     else {
  368       error  "FAIL: Cen tOS Docker  Image did  not impor t"
  369     }
  370   }
  371  
  372   // stage l atest arti fact
  373   def stageL atestArtif act(artifa ct){
  374       echo " stage the  latest bui ld artifac t(${artifa ct}) for d eployment"
  375       def ar tifact_nam e= artifac t.tokenize ('/').last ()
  376       def st aging = ST AGING_DIR. trim().toL owerCase()
  377       def la test = "${ WEB_BASEDI R}/latest_ centos_dev "
  378       echo " check for  TGT_STREAM "
  379       if(env .TGT_STREA M && env.T GT_STREAM? .trim()){
  380           ec ho "TGT_ST REAM found  (${TGT_ST REAM})"
  381           de f link=TGT _STREAM.tr im().toLow erCase()
  382           la test = "${ WEB_BASEDI R}/latest_ centos_${l ink}"
  383       }
  384       try {
  385           ec ho "check  ${staging}  directory  exist"
  386           sh  "[[ -d ${ staging} ] ] || sudo  mkdir -p $ {staging}"
  387           ec ho "fix di rectory pe rmissions"
  388           sh  """
  389              set -x
  390              sudo find  \$(dirname  ${STAGING _DIR}) -ty pe d -exec  chmod 075 5 {} \\;
  391           "" "
  392           ec ho "copy $ {artifact}  to ${stag ing}/"
  393           sh  "sudo cp  ${artifact } ${stagin g}/"
  394           ec ho "create  symbolic  link to st aged artif act"
  395           sh  "sudo ln  -sfn ${sta ging}/${ar tifact_nam e} ${lates t}"
  396           ec ho "verify  link crea ted"
  397           de f linkExis ts=sh (
  398                script:  "readlink  ${latest}" ,
  399                returnSt dout: true
  400                ).trim()
  401           sh  """
  402                if [[ -n  "${linkEx ists}" ]];  then
  403                    echo  "link exi sts for ${ latest}"
  404                else
  405                    echo  "link not  found ${l atest}"
  406                fi
  407           "" "
  408       } catc h(Exceptio n e){
  409           ec ho "someth ing bad ha ppened whi le staging  artifact,  throw and  fail"
  410           ec ho e.toStr ing()
  411           th row e
  412       }
  413   }
  414  
  415   // notifyH ipchat
  416   // will se nd color c oded notif ications t o hipchat
  417   //
  418   def notify Hipchat(St ring build Status = ' STARTED',  String hcR oom = '324 2078') {
  419   // build s tatus of n ull means  successful
  420     buildSta tus =  bui ldStatus ? : 'SUCCESS FUL'
  421  
  422     def last Build = cu rrentBuild .getPrevio usBuild()
  423  
  424     // Defau lt values
  425     def colo r = 'RED'
  426     def colo rCode = '# FF0000'
  427     def subj ect = "${b uildStatus }: Job '${ env.JOB_NA ME} [${env .BUILD_NUM BER}]'"
  428     def summ ary = "${s ubject} ($ {env.BUILD _URL})"
  429  
  430       // Ove rride defa ult values  based on  build stat us
  431     if (buil dStatus ==  'STARTED' ) {
  432       color  = 'YELLOW'
  433       colorC ode = '#FF FF00'
  434     }
  435     else if  (buildStat us == 'SUC CESSFUL')  {
  436       color  = 'GREEN'
  437       colorC ode = '#00 FF00'
  438       if( la stBuild &&  lastBuild .getResult ().toStrin g()=="FAIL URE" ){
  439         buil dStatus =  'FIXED'
  440       }
  441     }
  442     else if  (buildStat us == 'ABO RTED') {
  443       color  = 'PURPLE'
  444       colorC ode = '#80 0080'
  445     }
  446     else if  (buildStat us == 'UNS TABLE') {
  447       color  = 'GRAY'
  448       colorC ode = '#80 8080'
  449     }
  450     else {
  451       color  = 'RED'
  452       colorC ode = '#FF 0000'
  453     }
  454   }
  455  
  456   def notify BuildStatu s(String b uildStatus  = 'STARTE D') {
  457     // build  status of  null mean s successf ul
  458     buildSta tus =  bui ldStatus ? : 'SUCCESS FUL'
  459  
  460   //recipien tProviders  (optional )
  461   //$class:  CulpritsRe cipientPro vider
  462   //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.
  463   //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  
  464   //was a fa ilure it a lso includ es the cul prit list  from there .
  465  
  466   //$class:  Developers RecipientP rovider
  467   //Sends em ail to all  the peopl e who caus ed a chang e in the c hange set.
  468  
  469   //$class:  FailingTes tSuspectsR ecipientPr ovider
  470   //Sends em ail to the  list of u sers suspe cted of ca using a un it test to  begin fai ling.
  471   //This lis t includes  committer s and requ estors of  the build  where the  test began  to fail,
  472   //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.
  473  
  474   //$class:  FirstFaili ngBuildSus pectsRecip ientProvid er
  475   //Sends em ail to the  list of u sers suspe cted of ca using the  build to b egin faili ng.
  476  
  477   //$class:  ListRecipi entProvide r
  478   //Sends em ail to the  list of r ecipients  defined in  the "Proj ect Recipi ent List."
  479  
  480   //$class:  RequesterR ecipientPr ovider
  481   //Sends em ail to the  user who  initiated  the build.
  482  
  483   //$class:  UpstreamCo mitterReci pientProvi der
  484   //Sends em ail to the  list of u sers who c ommitted c hanges in  upstream b uilds that  triggered  this buil d
  485   // Default  values            Li stRecipien tProvider
  486     def reci pients=[[$ class: 'Li stRecipien tProvider' ]]
  487     def subj ect = "${b uildStatus }: Job '${ env.JOB_NA ME} [${env .BUILD_NUM BER}]'"
  488     def repl yto = "${e nv.DEFAULT _REPLYTO}"
  489     def mime Type = "te xt/html"
  490     def send to = "${en v.DEFAULT_ RECIPIENTS }"
  491     def deta ils = """
  492       <p>Job : '${env.J OB_NAME} b uild: [${e nv.BUILD_N UMBER}]':< /p>
  493       <p>Che ck console  output at  "<a href= "${env.BUI LD_URL}">$ {env.JOB_N AME} [${en v.BUILD_NU MBER}]</a> "</p>
  494       """
  495  
  496       // Ove rride defa ult values  based on  build stat us
  497     if (buil dStatus ==  'STARTED'  || buildS tatus == ' SUCCESSFUL ' || build Status ==  'FIXED') {
  498       recipi ents = [[$ class: 'De velopersRe cipientPro vider']]
  499     } 
  500    
  501     else if  (buildStat us == 'ABO RTED' || b uildStatus  == 'UNSTA BLE') {
  502       recipi ents = [[$ class: 'De velopersRe cipientPro vider']]
  503     }
  504     else {
  505       echo " unknown st atus"
  506       recipi ents = [[$ class: 'Cu lpritsReci pientProvi der'], [$c lass: 'Req uesterReci pientProvi der']]
  507     }
  508   //examples
  509   //Notify C ulprits an d Requeste r via defa ult EMail  plugin
  510   //step([$c lass: 'Mai ler', noti fyEveryUns tableBuild : true, re cipients:  emailextre cipients([ [$class: ' CulpritsRe cipientPro vider'], [ $class: 'R equesterRe cipientPro vider']])] )
  511  
  512   //Send an  email to a bc plus an y addresse s returned  by the pr oviders
  513   //emailext  body: 'A  Test EMail ', 
  514   //          recipient Providers:  [[$class:  'Develope rsRecipien tProvider' ], [$class : 'Request erRecipien tProvider' ]], 
  515   //          subject:  'Test', 
  516   //          to: 'abc'
  517     echo "se nd email t o recipien ts (${reci pients}) f or ${build Status}"
  518     echo """
  519         subj ect: ${sub ject},
  520         body : ${detail s},
  521         reci pientProvi ders: ${re cipients},
  522         repl yTo: ${rep lyto},
  523         to:  ${sendto}
  524         """
  525     mail (
  526         body : details,  
  527         cc:  ' PII ', 
  528         mime Type: 'tex t/html', 
  529         repl yTo: reply to, 
  530         subj ect: subje ct, 
  531         to:  sendto
  532         )
  533   }
  534  
  535   //save log  to worksp ace
  536   def getCon soleLog(){
  537     echo "ge tConsoleLo g: prepare  logfilena me to get  console lo g"
  538     def logF ilename="$ {JOB_URL}"
  539     def work spaceLog=" ${WORKSPAC E}/${JOB_B ASE_NAME}_ ${BUILD_NU MBER}_cons ole.log"
  540     echo "ge tConsoleLo g: console  log is ${ logFilenam e} (same a s job url) "
  541     logFilen ame=logFil ename.trim ().replace ("${JENKIN S_URL}","$ {JENKINS_H OME}/")
  542     echo "ge tConsoleLo g: console  log is ch anged to $ {logFilena me}"
  543     logFilen ame=logFil ename.trim ().replace All("job", "jobs")
  544     echo "ge tConsoleLo g: console  log is ch anged agai n to ${log Filename}"
  545     logFilen ame="${log Filename}b uilds/${BU ILD_NUMBER }/log"
  546     echo "ge tConsoleLo g: console  log is fi nally  ${l ogFilename }"
  547     echo "ge tConsoleLo g: prepare  to write  to ${works paceLog}"
  548     sh """
  549       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"
  550       sed -e  "s,\\x1b\ \[3[0-9][m GKA],,gm;s ,\\x1b\\[1 A,,gm;s,\\ x1b\\[2K,, gm;" "tmp. log" > "${ workspaceL og}"
  551       rm "tm p.log"
  552       echo " getConsole Log: verif y ${worksp aceLog} re ady for ar chival"
  553       if [[  -f "${work spaceLog}"  ]]
  554       then
  555         echo  "getConso leLog: loc al console  log (${wo rkspaceLog }) exists,  safe to p roceed"
  556       else
  557         echo  "getConso leLog: No  local cons ole log ($ {workspace Log}) foun d"
  558       fi
  559     """
  560   }
  561   // Require d due to J ENKINS-274 21
  562   @NonCPS
  563   List<List< ?>> mapToL ist(Map ma p) {
  564     return m ap.collect  { it ->
  565       [it.ke y, it.valu e]
  566     }
  567   }