43. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 4/18/2019 5:55:21 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.

43.1 Files compared

# Location File Last Modified
1 MCCF_EDI_TAS_TASCore v2.0_Build_10.zip\MCCF_EDI_TAS_API_Core Jenkinsfile Wed Apr 3 02:27:40 2019 UTC
2 MCCF_EDI_TAS_TASCore v2.0_Build_10.zip\MCCF_EDI_TAS_API_Core Jenkinsfile Tue Apr 16 15:27:25 2019 UTC

43.2 Comparison summary

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

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

43.4 Active regular expressions

No regular expressions were active.

43.5 Comparison detail

  1   pipeline()  {
  2     environm ent{
  3       def pr oductAcron ym="TAS_AP I"
  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 da teString =  new Date( currentBui ld.startTi meInMillis ).format(' yyyyMMdd_H Hmmss')
  9       def AR TIFACT_LOC ATION = "$ {WORKSPACE }/artifact s/${dateSt ring}"
  10       def DI ST_OUTPUT_ FILENAME=' '
  11       def DI ST_OUTPUT_ FILE=''
  12       def la stCommitID =''
  13       def pa ckageName= ''
  14       def WE B_BASEDIR= "/var/www/ html"
  15       def ST AGING_DIR= "${WEB_BAS EDIR}/dev/ tas"
  16       def ST AGING_URL= "${STAGE_U RL}"
  17       def mc cf_git_rep o="https:/ /bitbucket .org/halfa ker/mccf_t as_api"
  18       def bu ildResultU UID=''
  19       def TA SWorkspace ="${WORKSP ACE}"
  20       def RT C_COMPONEN T="MCCF_ED I_TAS_API_ Core"
  21       def pr oductBuild Dir="${RTC _COMPONENT }/src"
  22       def TA S_API_BUIL D_ARTIFACT S="Build_A rtifacts"
  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 br anch_name= ''
  27       def pr ojectname= "tasapi"
  28       def do ckerfile=" Dockerfile .api-full"
  29       def ap iDkrRepo=" tas/api"
  30       def ap iTAG="tas/ api:${prod uctMajorVe rsion}.${p roductMino rVersion}. ${productR ev}"
  31     }
  32     
  33     agent an y
  34     options  { timestam ps() }
  35     stages{
  36       stage( 'Prepare w orkspace w ith source  code') {
  37         step s{
  38           sc ript{
  39              def bldENV =ENV?.trim ().toUpper Case()
  40              echo "dete rmine regi on for ${b ldENV}"
  41              def region =bldENV[0. .2]
  42              echo "dete rmine main  env for r egion ${re gion}, (ak a ${bldENV })"
  43              def mainEN V=bldENV[- 3..-1]
  44              echo "dete rmine acti on for ${b ldENV}, (a ka ${regio n}, ${main ENV})"
  45              switch(reg ion){
  46                case "AW S":
  47                  echo " AWS enviro nment, Pre pare Halfa ker worksp ace"
  48                  dir("$ {RTC_COMPO NENT}"){
  49                     get HalfakerCo de()
  50                  }
  51                  break
  52                case "MA G":
  53                  echo ( "Initializ e workspac e from RTC ")
  54                  if (!T GT_STREAM? .trim().to UpperCase( ).equals(" DEV")){
  55                    STAG ING_DIR="$ {WEB_BASED IR}/rtc/ta s"
  56                  }
  57                  teamco ncert([
  58                    buil dType: [
  59                      bu ildDefinit ion: "${bu ildDefinit ionId}",
  60                      va lue: 'buil dDefinitio n'
  61                    ]
  62                  ])
  63                  echo ( "Verify co mponent ($ {RTC_COMPO NENT}) exi sts")
  64                  sh '''
  65                    if [ [ -d "${RT C_COMPONEN T}" ]]
  66                    then
  67                      ec ho "Compon ent (${RTC _COMPONENT }) exists,  safe to p roceed"
  68                    else
  69                      fa il "FAIL:  No compone nt (${RTC_ COMPONENT} ) found"
  70                    fi
  71                  '''
  72                  echo " MAG enviro nment, det ermine SRC _STREAM"
  73                  if(mai nENV.equal s("DEV") & &  SRC_STR EAM?.trim( ).toUpperC ase().equa ls("HAF")) {
  74                    echo  "need to  get HAF co de"
  75                    dir( "${localTM P}"){
  76                      ge tHalfakerC ode()
  77                      ec ho "need t o check la stGitCommi t against  lastGitTag "
  78                    }
  79                    dir( "${RTC_COM PONENT}"){
  80                      sh  'cp -p .p roject ../ tasapi.pro ject'
  81                      sh  'rsync -a cvWh "${lo calTMP}/"  . --exclud e ".git" - -del'
  82                      sh  'mv ../ta sapi.proje ct .projec t'
  83                    }
  84                  }
  85                  break
  86                default:
  87                  echo " local envi ronment, P repare Hal faker work space"
  88                  dir("$ {RTC_COMPO NENT}"){
  89                    getH alfakerCod e()
  90                  }
  91              }
  92           }
  93         }
  94       }
  95       stage( 'Pre-Build  Setup'){
  96         step s{
  97           ec ho ("creat e artifact  location  for jenkin s (${ARTIF ACT_LOCATI ON})")
  98           sh  'mkdir -p  ${ARTIFAC T_LOCATION }'
  99           ec ho "set fi nal packag eVersion"
  100           di r("${produ ctBuildDir }"){
  101              script{
  102                if(ENV?. trim().toU pperCase() .startsWit h("MAG")){
  103                  echo " building i n MAG, 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( 'Build and  Deploy')  {
  123         step s{
  124           di r ("${prod uctBuildDi r}"){
  125              script{
  126                  DIST_O UTPUT_FILE ="${packag eVersion}. tar"
  127                  DIST_O UTPUT_FILE NAME="${pa ckageVersi on}.tar.gz "
  128                  sh """
  129                    echo  "DIST_OUT PUT_FILE =  ${DIST_OU TPUT_FILE} "
  130                    echo  "DIST_OUT PUT_FILENA ME = ${DIS T_OUTPUT_F ILENAME}"
  131                    sudo  docker bu ild . -f $ {dockerfil e} -t "${a piTAG}"
  132                    sudo  docker im ages
  133                    sudo  docker sa ve ${apiTA G} > ${DIS T_OUTPUT_F ILE}
  134                    sudo  gzip ${DI ST_OUTPUT_ FILE}
  135                  """
  136                  if (fi leExists(" ${DIST_OUT PUT_FILENA ME}")) {
  137                    echo  "${DIST_O UTPUT_FILE NAME} crea ted, ready  to packag e"
  138                  }
  139                  else {
  140                    erro r "FAIL: $ {DIST_OUTP UT_FILENAM E} not rea dy"
  141                  }
  142              }
  143           }
  144         }
  145       }
  146       stage( 'Verify Do cker Image ') {
  147         step s{
  148           ec ho "Verify  package $ {DIST_OUTP UT_FILENAM E}"
  149           di r ("${prod uctBuildDi r}"){
  150              //sh "sudo  docker im port ${DIS T_OUTPUT_F ILENAME} $ {apiTAG}"
  151              //echo "Ve rify TAS A PI Docker  Image Impo rted Succe ssfully"
  152              getInspect ionStatus( )
  153           }
  154         }
  155       }
  156       stage( 'Stage Pac kage') {
  157         step s{
  158           ec ho "stage  the packag ed distrib ution (${D IST_OUTPUT _FILENAME} ) for ${pa ckageVersi on}"
  159           di r ("${prod uctBuildDi r}"){
  160              stageLates tArtifact( "${DIST_OU TPUT_FILEN AME}")
  161           }
  162         }
  163       }
  164     }
  165     post{
  166     // add t he cleanup  to remove  the image s
  167       always {
  168         echo  "POST alw ays: all t asks are c ompleted,  collecting  environme nt variabl es to ${WO RKSPACE}/$ {BUILD_TAG }.log"
  169         sh ' printenv > > $WORKSPA CE/$BUILD_ TAG.log'
  170         echo  "POST alw ays: archi ving all l ogs and ar tifacts sp ecified"
  171         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: '']
  172       }
  173       succes s{
  174         echo  'POST suc cess: chec k environm ent to det ermine com mit action s'
  175         scri pt {
  176           de f myENV="$ {ENV}"
  177           de f subENV=m yENV[0..2]
  178           de f MAG_ARTI FACT_LOCAT ION = "${W ORKSPACE}/ ${TAS_API_ BUILD_ARTI FACTS}/${p ackageVers ion}"
  179           ec ho "POST s uccess: de termine pr oper commi t action f or ${myENV }, (aka ${ subENV})"
  180           sw itch(subEN V.toUpperC ase()){
  181              case "AWS" :
  182                echo "PO ST success : AWS envi ronment, u se git to  tag this b uild"
  183                gitTagBu ild()
  184                echo "PO ST success : reset cu rrentBuild Result '${ currentBui ld.result  }' if null  or not su ccess"
  185                if(curre ntBuild.re sult != 'S UCCESS'){  currentBui ld.result= 'SUCCESS'}
  186                echo "PO ST success : in AWS,  make MSTEA MS notific ation '${c urrentBuil d.result}' "
  187                notifyMS Teams(curr entBuild.r esult)
  188                break
  189              case "MAG" :
  190                echo "PO ST success : copy pac kaged arti fact (${DI ST_OUTPUT_ FILE}) to  ${TAS_API_ BUILD_ARTI FACTS}"
  191                sh """
  192                  pwd
  193                  mkdir  -p "${MAG_ ARTIFACT_L OCATION}"
  194                  mv "${ WORKSPACE} /${product BuildDir}/ ${DIST_OUT PUT_FILENA ME}" "${MA G_ARTIFACT _LOCATION} /"
  195                  echo " POST succe ss: check  ${MAG_ARTI FACT_LOCAT ION}/${DIS T_OUTPUT_F ILENAME}"
  196                  if [[  -f "${MAG_ ARTIFACT_L OCATION}/$ {DIST_OUTP UT_FILENAM E}" ]]
  197                  then
  198                    echo  "POST suc cess: Arti fact (${MA G_ARTIFACT _LOCATION} /${DIST_OU TPUT_FILEN AME}) exis ts, safe t o proceed"
  199                  else
  200                    fail  "FAIL: PO ST success : No artif act (${MAG _ARTIFACT_ LOCATION}/ ${DIST_OUT PUT_FILENA ME}) found "
  201                  fi
  202                 """
  203                echo "cl eanup prio r to check in and del iver"
  204                dir("${p roductBuil dDir}"){
  205                  sh 'rm  -rf **/lo gs'
  206                  sh 'rm  -rf **/ta rget'
  207                  sh 'fi nd . -name  "*.log" - type f -de lete'
  208                  sh 'rm  -rf *@*'
  209                }
  210                dir("${R TC_COMPONE NT}"){
  211                  sh 'rm  -rf **/lo gs'
  212                  sh 'rm  -rf **/ta rget'
  213                  sh 'fi nd . -name  "*.log" - type f -de lete'
  214                  sh 'rm  -rf *@*'
  215                }
  216                rtcCheck in()
  217                rtcDeliv er()
  218                echo "PO ST success : send ema il notific ation '${c urrentBuil d.result}' "
  219                notifyBu ildStatus( currentBui ld.result)
  220              break
  221              default:
  222               echo "POS T success:  local env ironment,  send no no tices"
  223               echo "POS T success:  local env ironment,  do not com mit any ta g"
  224           }
  225         }
  226         echo  "POST suc cess: coll ecting con sole log"
  227         getC onsoleLog( )
  228         echo  "POST suc cess: arch iving all  logs and a rtifacts s pecified"
  229         arch iveArtifac ts allowEm ptyArchive : true, ar tifacts: ' **/*.log,  *.html, *. tar.gz' ,  onlyIfSucc essful: fa lse
  230         echo  'POST suc cess: Perf orming cle anup tasks  after bui ld success '
  231         dele teDir()
  232       }
  233       // Per form tasks  upon erro r
  234       failur e{
  235         scri pt{
  236           ec ho "POST f ailure: re set curren tBuildResu lt '${curr entBuild.r esult }' i f null or  not failed "
  237           if (currentBu ild.result  != 'FAILU RE'){ curr entBuild.r esult='FAI LURE'}
  238           if (BUILD_URL .toLowerCa se().conta ins("aws") ){
  239              echo "POST  failure:  in AWS, ma ke MSTEAMS  notificat ion '${cur rentBuild. result}'"
  240              notifyMSTe ams(curren tBuild.res ult)
  241           }
  242           if (ENV.toLow erCase().c ontains("l ocal")){
  243                echo "PO ST failure : local en vironment,  send no n otices"
  244           }
  245           el se{
  246              echo "POST  failure:  send email  notificat ion '${cur rentBuild. result}'"
  247              notifyBuil dStatus(cu rrentBuild .result)
  248           }
  249         }
  250         echo  "POST fai lure: coll ecting con sole log"
  251         getC onsoleLog( )
  252         echo  "POST fai lure: arch iving all  logs and a rtifacts s pecified"
  253         arch iveArtifac ts allowEm ptyArchive : true, ar tifacts: ' **/*.log,  *.tar.gz,  *.tar' , o nlyIfSucce ssful: fal se
  254         echo  'POST fai lure: Perf orming cle anup tasks  for build  failure'
  255         dele teDir()
  256       }
  257     }
  258   }
  259   // FUNCTIO NS SPECIFI C TO HALFA KER BEGIN
  260  
  261   // FUNCTIO NS USED
  262    // git fu nctions
  263   // Functio n to get b ranch name
  264   def getBra nchName(){
  265     def bran ch="${GIT_ BRANCH}"
  266     return b ranch.toke nize('/')[ 1].toLower Case()
  267   }
  268  
  269   // Functio n to load  workspace
  270   def getHal fakerCode( ){
  271     branch_n ame=getBra nchName()
  272     echo "($ {branch_na me}), [${G IT_BRANCH} ]"
  273     echo "ge t the code "
  274     sh """
  275       git co nfig --glo bal core.a utocrlf fa lse
  276       git co nfig --glo bal creden tial.helpe r 'cache - -timeout=3 600'
  277     """
  278     git cred entialsId:  'jenkins_ build', ur l: "${mccf _git_repo} ", poll: f alse, bran ch: "${bra nch_name}"
  279     echo ("g et last gi t tag")
  280     lastGitT ag=gitDesc ribe()
  281     def last Commit=get LastGitCom mit()
  282     echo ("c heck lastG itTag (${l astGitTag} )")
  283     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")
  284     if ( las tGitTag?.t rim() ){
  285       echo ( "Ready to  build ${la stGitTag}  (${lastCom mit})")
  286     }
  287     else {
  288       error( "FAIL: no  source pul led from $ {mccf_git_ repo}")
  289     }
  290   }
  291  
  292   def gitDes cribe(){
  293     echo "ge tting last  git tag"
  294     def MYIN FO
  295     def tagE xists=sh(r eturnStdou t: true, s cript: 'gi t tag --li st').trim( )
  296     echo "ta g: ${tagEx ists}"
  297     MYINFO=s h(returnSt dout: true , script:  'git descr ibe --alwa ys').trim( )
  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   // Functio n for git  last commi t
  303   def getLas tGitCommit (){
  304     echo "ge tting last  git commi t"
  305     def LAST _COMMIT
  306     LAST_COM MIT = sh (
  307       script : 'git rev -parse HEA D',
  308       return Stdout: tr ue
  309     ).trim()
  310     echo ("t he last co mmit is ${ LAST_COMMI T[0..6]}")
  311     LAST_COM MIT[0..6]
  312   }
  313  
  314   // Functio n for git  changesets
  315   def getCha ngesets(){
  316       def ch angeLogSet s = curren tBuild.cha ngeSets
  317       echo " reviewing  changesets :"
  318       def co mmitMessag e=""
  319       for (i nt i = 0;  i < change LogSets.si ze(); i++)  {
  320           de f entries  = changeLo gSets[i].i tems
  321           fo r (int j =  0; j < en tries.leng th; j++) {
  322                def entr y = entrie s[j]
  323                commitMe ssage="${c ommitMessa ge} \n ${e ntry.commi tId} by ${ entry.auth or} on ${n ew Date(en try.timest amp)}"
  324                echo "${ entry.comm itId} by $ {entry.aut hor} on ${ new Date(e ntry.times tamp)}: ${ entry.msg} "
  325                def file s = new Ar rayList(en try.affect edFiles)
  326                for (int  k = 0; k  < files.si ze(); k++)  {
  327                    def  file = fil es[k]
  328                    echo  "  ${file .editType. name} ${fi le.path}"
  329                }
  330           }
  331       }
  332       return  "${commit Message}"
  333   }
  334  
  335   // Functio n for git  tag
  336   def gitTag Build(){
  337     withCred entials([u sernamePas sword(cred entialsId:  'jenkins_ build', pa sswordVari able: 'jen kinsPass',  usernameV ariable: ' jenkinsUse r')]) {
  338       def MY HOSTNAME=g etHostname ()
  339       def co mmit_messa ge = /"jen kins-${JOB _BASE_NAME }-${BUILD_ NUMBER}-${ MYHOSTNAME }"/
  340       sh 'gi t config - -list'
  341       echo " set the us er.name, u ser.email"
  342       def uE mail = /"m ccfsystema dmins@half aker.com"/
  343       sh """
  344         git  config use r.name "${ jenkinsUse r}"
  345         git  config use r.email ${ uEmail}
  346         git  config --g lobal push .default s imple
  347         git  config ali as.version log "notes  --ref=ver sionlog ap pend"
  348         git  config --a dd remote. origin.pus h '+refs/n otes/*:ref s/notes/*'
  349         git  config --a dd remote. origin.fet ch '+refs/ notes/*:re fs/notes/* '
  350         git  remote set -url origi n ${GIT_UR L}
  351         git  config --l ist
  352       """
  353       echo " append ver sion note  to this co mmit"
  354       addGit VersionLog ()
  355       echo " tag this c ommit ${pa ckageVersi on}"
  356       sh """
  357         git  tag -a ${p ackageVers ion} -m '$ {commit_me ssage}' ${ lastCommit ID}
  358         echo  "push cha nges to re mote"
  359         git  push origi n --tags - -verbose
  360       """
  361     }
  362   }
  363  
  364   // Functio n for addi ng git ver sion log
  365   def addGit VersionLog (){
  366     def last BuildDate= new Date(c urrentBuil d.startTim eInMillis) .format('M MM dd, yyy y HH:mm:ss  Z')
  367     def vers ionString= "version:  ${packageV ersion}"
  368     def buil dDateStrin g="lastBui ldDate: ${ lastBuildD ate}"
  369     def dist ributionSt ring="dist ributionFi leName: <s taging_url >/${DIST_O UTPUT_FILE NAME}"
  370     sh """
  371       git ve rsionlog $ {lastCommi tID} -m "$ {versionSt ring}, ${b uildDateSt ring}, ${d istributio nString}"
  372     """
  373   }
  374   // GIT FUN CTIONS END
  375   //  helper  functions
  376  
  377   // Functio n to stage  distribut ion packag e
  378   def stageL atestArtif act(artifa ct){
  379       echo " stage the  latest bui ld artifac t(${artifa ct}) for d eployment"
  380       def ar tifact_nam e= artifac t.tokenize ('/').last ()
  381       def st aging = ST AGING_DIR. trim().toL owerCase()
  382       def la test = "${ WEB_BASEDI R}/latest_ tasapi_dev "
  383       echo " check for  TGT_STREAM "
  384       if(env .branch_na me && env. branch_nam e?.trim(). toLowerCas e() != 'ma ster'){
  385         echo  "staging  for branch  build (${ branch_nam e})"
  386         def  link=branc h_name?.tr im().toLow erCase()
  387         late st = "${WE B_BASEDIR} /latest_ta sapi_${lin k}"
  388       }
  389       else{
  390         if(e nv.TGT_STR EAM && env .TGT_STREA M?.trim()) {
  391           ec ho "TGT_ST REAM found  (${TGT_ST REAM})"
  392           de f link=TGT _STREAM.tr im().toLow erCase()
  393           la test = "${ WEB_BASEDI R}/latest_ tasapi_${l ink}"
  394         }
  395       }
  396       try {
  397           ec ho "check  ${staging}  directory  exist"
  398           sh  "[[ -d ${ staging} ] ] || sudo  mkdir -p $ {staging}"
  399           ec ho "fix di rectory pe rmissions"
  400           sh  """
  401              set -x
  402              sudo find  \$(dirname  ${STAGING _DIR}) -ty pe d -exec  chmod 075 5 {} \\;
  403           "" "
  404           ec ho "copy $ {artifact}  to ${stag ing}/"
  405           sh  "sudo cp  ${artifact } ${stagin g}/"
  406           ec ho "create  symbolic  link to st aged artif act"
  407           sh  "sudo ln  -sfn ${sta ging}/${ar tifact_nam e} ${lates t}"
  408           ec ho "verify  link crea ted"
  409           de f linkExis ts=sh (
  410                script:  "readlink  ${latest}" ,
  411                returnSt dout: true
  412                ).trim()
  413           sh  """
  414                if [[ -n  "${linkEx ists}" ]];  then
  415                    echo  "link exi sts for ${ latest}"
  416                else
  417                    echo  "link not  found ${l atest}"
  418                fi
  419           "" "
  420       } catc h(Exceptio n e){
  421           ec ho "someth ing bad ha ppened whi le staging  artifact,  throw and  fail"
  422           ec ho e.toStr ing()
  423           th row e
  424       }
  425   }
  426  
  427   // Functio n for gett ing the ho stname
  428   def getHos tname(){
  429     def THIS HOSTNAME
  430     if(isUni x()){
  431       THISHO STNAME = s h (
  432         scri pt: 'hostn ame',
  433         retu rnStdout:  true
  434       ).trim ()
  435     }
  436     else {
  437       THISHO STNAME = b at (
  438         scri pt: 'hostn ame',
  439         retu rnStdout:  true
  440       ).trim ()
  441     }
  442     THISHOST NAME
  443   }
  444  
  445   def getPac kageName() {
  446     echo "ge tting pack age name"
  447     def MYNA ME
  448     MYNAME =  sh (
  449         scri pt: 'npm r un env | g rep npm_pa ckage_name  | cut -d  \"=\" -f 2 ',
  450         retu rnStdout:  true
  451       ).trim ()
  452     MYNAME
  453   }
  454  
  455   //  get do cker image  inspect s tatus
  456   def getIns pectionSta tus(){
  457     def insp ectionStat us=sh (
  458     script:  "sudo dock er image i nspect ${a piTAG}",
  459     returnSt atus: true
  460     )
  461     if (insp ectionStat us == 0){
  462       echo " TAS API Do cker Image  inspectio n processe d successf ully"
  463       return  0
  464       }
  465     else {
  466       error  "FAIL: TAS  API Docke r inspecti on process  FAILED"
  467     }
  468   }
  469  
  470   // Functio n to notif y regardin g build st atus
  471  
  472   def notify BuildStatu s(String b uildStatus  = 'STARTE D') {
  473     // build  status of  null mean s successf ul
  474     buildSta tus =  bui ldStatus ? : 'SUCCESS FUL'
  475  
  476   //recipien tProviders  (optional )
  477   //$class:  CulpritsRe cipientPro vider
  478   //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.
  479   //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
  480   //was a fa ilure it a lso includ es the cul prit list  from there .
  481  
  482   //$class:  Developers RecipientP rovider
  483   //Sends em ail to all  the peopl e who caus ed a chang e in the c hange set.
  484  
  485   //$class:  FailingTes tSuspectsR ecipientPr ovider
  486   //Sends em ail to the  list of u sers suspe cted of ca using a un it test to  begin fai ling.
  487   //This lis t includes  committer s and requ estors of  the build  where the  test began  to fail,
  488   //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.
  489  
  490   //$class:  FirstFaili ngBuildSus pectsRecip ientProvid er
  491   //Sends em ail to the  list of u sers suspe cted of ca using the  build to b egin faili ng.
  492  
  493   //$class:  ListRecipi entProvide r
  494   //Sends em ail to the  list of r ecipients  defined in  the "Proj ect Recipi ent List."
  495  
  496   //$class:  RequesterR ecipientPr ovider
  497   //Sends em ail to the  user who  initiated  the build.
  498  
  499   //$class:  UpstreamCo mitterReci pientProvi der
  500   //Sends em ail to the  list of u sers who c ommitted c hanges in  upstream b uilds that  triggered  this buil d
  501   // Default  values            Li stRecipien tProvider
  502     def reci pients=[[$ class: 'Li stRecipien tProvider' ]]
  503     def subj ect = "${b uildStatus }: Job '${ env.JOB_NA ME} [${env .BUILD_NUM BER}]'"
  504     def repl yto = "${e nv.DEFAULT _REPLYTO}"
  505     def mime Type = "te xt/html"
  506     def send to = "${en v.DEFAULT_ RECIPIENTS }"
  507     def deta ils = """
  508       <p>Job : '${env.J OB_NAME} b uild: [${e nv.BUILD_N UMBER}]':< /p>
  509       <p>Che ck console  output at  "<a href= "${env.BUI LD_URL}">$ {env.JOB_N AME} [${en v.BUILD_NU MBER}]</a> "</p>
  510       """
  511  
  512       // Ove rride defa ult values  based on  build stat us
  513     if (buil dStatus ==  'STARTED'  || buildS tatus == ' SUCCESSFUL ' || build Status ==  'FIXED') {
  514       recipi ents = [[$ class: 'De velopersRe cipientPro vider']]
  515     }
  516  
  517     else if  (buildStat us == 'ABO RTED' || b uildStatus  == 'UNSTA BLE') {
  518       recipi ents = [[$ class: 'De velopersRe cipientPro vider']]
  519     }
  520     else {
  521       echo " unknown st atus"
  522       recipi ents = [[$ class: 'Cu lpritsReci pientProvi der'], [$c lass: 'Req uesterReci pientProvi der']]
  523     }
  524   //examples
  525   //Notify C ulprits an d Requeste r via defa ult EMail  plugin
  526   //step([$c lass: 'Mai ler', noti fyEveryUns tableBuild : true, re cipients:  emailextre cipients([ [$class: ' CulpritsRe cipientPro vider'], [ $class: 'R equesterRe cipientPro vider']])] )
  527  
  528   //Send an  email to a bc plus an y addresse s returned  by the pr oviders
  529   //emailext  body: 'A  Test EMail ',
  530   //          recipient Providers:  [[$class:  'Develope rsRecipien tProvider' ], [$class : 'Request erRecipien tProvider' ]],
  531   //          subject:  'Test',
  532   //          to: 'abc'
  533     echo "se nd email t o recipien ts (${reci pients}) f or ${build Status}"
  534     echo """
  535         subj ect: ${sub ject},
  536         body : ${detail s},
  537         reci pientProvi ders: ${re cipients},
  538         repl yTo: ${rep lyto},
  539         to:  ${sendto}
  540         """
  541     mail (
  542         body : details,
  543         cc:  'PII',
  544         mime Type: 'tex t/html',
  545         repl yTo: reply to,
  546         subj ect: subje ct,
  547         to:  sendto
  548         )
  549   }
  550  
  551   def notify MSTeams(St ring build Status = ' STARTED')  {
  552   // build s tatus of n ull means  successful
  553     buildSta tus =  bui ldStatus ? : 'SUCCESS FUL'
  554  
  555     def last Build = cu rrentBuild .getPrevio usBuild()
  556  
  557     // Defau lt values
  558     def colo rCode = 'C 50E2E'
  559     def subj ect = "${e nv.ENV} :  Job '${env .JOB_NAME}  [${env.BU ILD_NUMBER }]'"
  560     def summ ary = "${s ubject} [V iew on Jen kins](${en v.BUILD_UR L})"
  561  
  562       // Ove rride defa ult values  based on  build stat us
  563     if (buil dStatus ==  'STARTED' ) {
  564       colorC ode = 'FFF F00'
  565     }
  566     else if  (buildStat us == 'SUC CESSFUL')  {
  567       colorC ode = '05b 222'
  568       if( la stBuild &&  lastBuild .getResult ().toStrin g()=="FAIL URE" ){
  569         buil dStatus =  'FIXED'
  570       }
  571     }
  572     else if  (buildStat us == 'ABO RTED') {
  573       colorC ode = '800 080'
  574     }
  575     else if  (buildStat us == 'UNS TABLE') {
  576       colorC ode = '808 080'
  577     }
  578     else {
  579       color  = 'RED'
  580       colorC ode = '#FF 0000'
  581     }
  582  
  583     // Send  notificati ons
  584     echo "se nd notice  of ${build Status} to  MSTeams"
  585     def chan gesMessage =getChange sets()
  586     if(build Status ==  'SUCCESSFU L'){
  587       echo " only send  notice if  previous b uild was n ot success ful"
  588       if( la stBuild &&  lastBuild .getResult ().toStrin g()!="SUCC ESSFUL" ){
  589         echo  "the prev ious build  ${lastBui ld.getId() } was not  successful , send upd ate"
  590         offi ce365Conne ctorSend (
  591           me ssage: sum mary + ":  changesets :  " + cha ngesMessag e,
  592           we bhookUrl:  "${env.off iceWebhook Url}",
  593           co lor: "${co lorCode}",
  594           st atus: "${b uildStatus }"
  595         )
  596       }
  597       else {
  598         echo  "the prev ious build  was " + l astBuild.g etResult() .toString( )
  599       }
  600     }
  601     else {
  602       echo " this build  is ${buil dStatus}"
  603       office 365Connect orSend (
  604         mess age: summa ry + ": ch angesets:   " + chang esMessage,
  605         webh ookUrl: "$ {env.offic eWebhookUr l}",
  606         colo r: "${colo rCode}",
  607         stat us: "${bui ldStatus}"
  608       )
  609     }
  610   }
  611  
  612   // Functio n to save  log to wor kspace
  613   def getCon soleLog(){
  614     echo "ge tConsoleLo g: prepare  logfilena me to get  console lo g"
  615     def logF ilename="$ {JOB_URL}"
  616     def work spaceLog=" ${WORKSPAC E}/${JOB_B ASE_NAME}_ ${BUILD_NU MBER}_cons ole.log"
  617     echo "ge tConsoleLo g: console  log is ${ logFilenam e} (same a s job url) "
  618     logFilen ame=logFil ename.trim ().replace ("${JENKIN S_URL}","$ {JENKINS_H OME}/")
  619     echo "ge tConsoleLo g: console  log is ch anged to $ {logFilena me}"
  620     logFilen ame=logFil ename.trim ().replace All("job", "jobs")
  621     echo "ge tConsoleLo g: console  log is ch anged agai n to ${log Filename}"
  622     logFilen ame="${log Filename}b uilds/${BU ILD_NUMBER }/log"
  623     echo "ge tConsoleLo g: console  log is fi nally  ${l ogFilename }"
  624     echo "ge tConsoleLo g: prepare  to write  to ${works paceLog}"
  625     sh """
  626       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"
  627       sed -e  "s,\\x1b\ \[3[0-9][m GKA],,gm;s ,\\x1b\\[1 A,,gm;s,\\ x1b\\[2K,, gm;" "tmp. log" > "${ workspaceL og}"
  628       rm "tm p.log"
  629       echo " getConsole Log: verif y ${worksp aceLog} re ady for ar chival"
  630       if [[  -f "${work spaceLog}"  ]]
  631       then
  632         echo  "getConso leLog: loc al console  log (${wo rkspaceLog }) exists,  safe to p roceed"
  633       else
  634         echo  "getConso leLog: No  local cons ole log ($ {workspace Log}) foun d"
  635       fi
  636     """
  637   }
  638  
  639   // FUNCTIO NS SPECIFI C TO HALFA KER END
  640  
  641   // RTC FUN CTIONS BEG IN
  642   // Functio n to check -in code t o Rational  Team Conc ert
  643   def rtcChe ckin(){
  644     withCred entials([u sernamePas sword(cred entialsId:  'RTC_BUIL D', userna meVariable : 'rtcUser ', passwor dVariable:  'rtcPass' )]) {
  645     // avail able as an  env varia ble, but w ill be mas ked if you  try to pr int it out  any which  way
  646       def MY HOSTNAME=g etHostname ()
  647       def la stBuildDat e=new Date (currentBu ild.startT imeInMilli s).format( 'MMM dd, y yyy HH:mm: ss Z')
  648       def ve rsionStrin g="version : ${packag eVersion}"
  649       def bu ildDateStr ing="lastB uildDate:  ${lastBuil dDate}"
  650       def di stribution String="di stribution FileName:  <staging_u rl>/${DIST _OUTPUT_FI LENAME}"
  651       def co mmitCommen t = /"${ve rsionStrin g}, ${buil dDateStrin g}, ${dist ributionSt ring},jenk ins-${JOB_ BASE_NAME} -${BUILD_N UMBER}-${M YHOSTNAME} "/
  652       def wo rkitem = " ${RTC_WORK ITEM}"
  653       def co mponents=  ["${RTC_CO MPONENT}"]
  654  
  655       echo " show scm s tatus"
  656       sh """
  657         ${sc mtool} sho w status - u ${rtcUse r} -P ${rt cPass} -v  --all -d $ {TASWorksp ace}
  658         echo  "----- -- --- -----  ----- ---- -"
  659       """
  660  
  661       echo " prepare to  checkin c omponents"
  662       for (c omponent i n componen ts){
  663         echo  "loop thr ough each  file in $c omponent"
  664         sh " ""
  665           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} -- delim-none  --checkin -deleted - v -d ${TAS Workspace}  ${TASWork space}/{}  \\;
  666         """
  667         echo  "${scmtoo l} checkin  $componen t/*"
  668         sh " ${scmtool}  checkin - u ${rtcUse r} -P ${rt cPass} --c omment ${c ommitComme nt} --work item ${wor kitem} --d elim-none  --checkin- deleted -v  -d ${TASW orkspace}  ${TASWorks pace}/$com ponent/*"
  669         echo  "----- -- --- -----  ----- ---- -"
  670       }
  671       // the  following  is not va lid until  rtc 6.0.4
  672       //step ([$class:  'RTCPostBu ildDeliver Publisher' , failOnEr ror: true] )
  673     }
  674   }
  675  
  676   // Functio n to deliv er code to  Rational  Team Conce rt
  677   def rtcDel iver(){
  678     withCred entials([u sernamePas sword(cred entialsId:  'RTC_BUIL D', userna meVariable : 'rtcUser ', passwor dVariable:  'rtcPass' )]) {
  679     // avail able as an  env varia ble, but w ill be mas ked if you  try to pr int it out  any which  way
  680       def wo rkitem = " ${RTC_WORK ITEM}"
  681       echo " show scm s tatus"
  682       sh """
  683         ${sc mtool} sho w status - u ${rtcUse r} -P ${rt cPass} -v  --all -d $ {TASWorksp ace}
  684         echo  "----- -- --- -----  ----- ---- -"
  685       """
  686       echo " RTC ${rtcU ser} deliv er "
  687       def de liverStatu s=sh (
  688       script : "${scmto ol} delive r -u ${rtc User} -P $ {rtcPass}  -v",
  689       return Status: tr ue
  690       )
  691       if (de liverStatu s == 0 ||  deliverSta tus == 52  || deliver Status ==  53){
  692         echo  "Deliver  succeeded"
  693         retu rn 0
  694       }
  695     else if  (deliverSt atus == 11 ) {
  696       echo " Accept inc oming chan ges"
  697       def ac ceptStatus =sh (
  698       script : "${scmto ol} accept  -u ${rtcU ser} -P ${ rtcPass} - v",
  699       return Status: tr ue
  700     )
  701       if (ac ceptStatus  == 0) {
  702         def  redoDelive rStatus=sh  (
  703       script : "${scmto ol} delive r -u ${rtc User} -P $ {rtcPass}  -v",
  704       return Status: tr ue
  705       )
  706       if (re dodeliverS tatus == 0  || delive rStatus ==  52 || del iverStatus  == 53){
  707         echo  "Accept a nd Deliver  succeeded "
  708         retu rn 0
  709       }
  710       }
  711     }
  712       else {
  713       curren tBuild.res ult='FAILE D'
  714         erro r("FAIL: S CM deliver  failed wi th ${deliv erStatus}" )
  715       }
  716       // the  following  is not va lid until  rtc 6.0.4
  717       //step ([$class:  'RTCPostBu ildDeliver Publisher' , failOnEr ror: true] )
  718     }
  719   }
  720  
  721   // Functio n to basel ine code t o Rational  Team Conc ert
  722   def rtcBas eline(){
  723     withCred entials([u sernamePas sword(cred entialsId:  'RTC_BUIL D', userna meVariable : 'rtcUser ', passwor dVariable:  'rtcPass' )]) {
  724     // avail able as an  env varia ble, but w ill be mas ked if you  try to pr int it out  any which  way
  725       echo " RTC list w orkspaces  "
  726       def wo rkspaceLis t=sh (
  727       script : "${scmto ol} list w orkspaces  -r local - v",
  728       return Stdout: tr ue
  729       ).trim ()
  730  
  731       echo " workspace:  ${workspa ceList}"
  732  
  733       echo " RTC ${rtcU ser} creat e baseline  "
  734       sh """
  735         ${sc mtool} cre ate baseli ne -u ${rt cUser} -P  ${rtcPass}  --all ${w orkspaceLi st} ${pack ageVersion }
  736       """
  737       // the  following  is not va lid until  rtc 6.0.4
  738       //step ([$class:  'RTCPostBu ildDeliver Publisher' , failOnEr ror: true] )
  739     }
  740   }
  741   // RTC FUN CTIONS END
  742  
  743   // JENKINS  SPECIFIC  FUNCTION B EGIN
  744   // Require d due to J ENKINS-274 21
  745   @NonCPS
  746   List<List< ?>> mapToL ist(Map ma p) {
  747     return m ap.collect  { it ->
  748       [it.ke y, it.valu e]
  749     }
  750   }
  751   // JENKINS  SPECIFIC  FUNCTION E ND
  752