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

317.1 Files compared

# Location File Last Modified
1 MCCF_EDI_TAS_TASCore v2.0_Build_10.zip\MCCF_EDI_TAS_DevOps\mccf_devops createNodeCI.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 createNodeCI.jenkinsfile Tue Apr 16 15:27:26 2019 UTC

317.2 Comparison summary

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

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

317.4 Active regular expressions

No regular expressions were active.

317.5 Comparison detail

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