1. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 10/2/2017 1:40:03 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

1.1 Files compared

# Location File Last Modified
1 chef-repo.zip\chef-repo\jenkins\scripts JobManager.groovy Fri Jul 1 16:58:42 2016 UTC
2 chef-repo.zip\chef-repo\jenkins\scripts JobManager.groovy Mon Oct 2 12:37:31 2017 UTC

1.2 Comparison summary

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

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

1.4 Active regular expressions

No regular expressions were active.

1.5 Comparison detail

  1  
  2  
  3   import gro ovy.text.S impleTempl ateEngine
  4  
  5   class JobM anager {
  6  
  7       def je nkinsBaseU rl = 'http ://localho st:8080'
  8  
  9       def wo rkspaceDir  = System. getPropert y('workspa ceDir')
  10       def gi tBranch =  System.get Property(' gitBranch' ).replace( 'origin/',  '')
  11  
  12       def us ername = n ull
  13       def pa ssword = n ull
  14  
  15       public  JobManage r( String  username,  String pas sword){
  16           th is.usernam e = userna me
  17           th is.passwor d = passwo rd
  18       }
  19  
  20       public  static vo id main(ar gs){
  21           de f self = n ew JobMana ger(System .getProper ty('userna me', null) , System.g etProperty ('password ', null));
  22           se lf.run();
  23       }
  24  
  25       def ru n(){
  26  
  27           if  (gitBranc h == 'HEAD ')
  28           {
  29                gitBranc h = 'git s ymbolic-re f refs/rem otes/origi n/HEAD'.ex ecute().te xt.trim(). replace('r efs/remote s/origin/' , '')
  30                println  "resetting  current b ranch name  to $gitBr anch, was  pointed to  HEAD"
  31           }
  32  
  33           de f dir = ne w File('./ jenkins')
  34           di r.traverse (
  35                type:gro ovy.io.Fil eType.FILE S,
  36                nameFilt er:~/.*\.k in/,
  37                maxDepth :0
  38           )  { kinBuild FilePath - >
  39                println  "should we  process t his kin fi le: ${kinB uildFilePa th}"
  40                if (gitB ranch != ' next' && k inBuildFil ePath.name .contains( 'infrastru cture')) {
  41                    prin tln "skipp ing this k in file as  we are no t on the n ext branch "
  42                  } else if  (System.ge tenv('JENK INS_URL'). contains(' DNS     ') ^ kinBu ildFilePat h.name.con tains('ede ')) {
  43                    prin tln "skipp ing this k in file: i f we are i n ede, the  kin file  is not for  ede; if w e are not  in ede, th e kin file  is for ed e"
  44                } else {
  45                    prin tln "proce ssing this  kin file"
  46                    buil dAndPublis hJobs(kinB uildFilePa th.absolut ePath)
  47                }
  48           }
  49       }
  50  
  51       def bu ildAndPubl ishJobs(St ring kinBu ildFilePat h) {
  52           bu ildJobConf ig(kinBuil dFilePath) .each { Jo b job ->
  53                if (!doe sJobExist( job.name))  {
  54                    crea teJob(job)
  55                } else {
  56                    upda teJob(job)
  57                }
  58           }
  59       }
  60  
  61       @GrabR esolver(na me = "nexu s", root =  "https:// store.vist acore.us/n exus/conte nt/groups/ public")
  62       @Grab( 'jenkins:j enkins-cli :1.642.1')
  63       def ru nCliComman d(List<Str ing> args,  InputStre am input =  System.in ,
  64           Ou tputStream  output =  System.out , OutputSt ream err =  System.er r)
  65       {
  66  
  67           de f hudson.c li.CLI cli  = new hud son.cli.CL I(jenkinsB aseUrl.toU RI().toURL ())
  68           if  ( usernam e != null  && passwor d != null) {
  69                args.add ('--userna me')
  70                args.add (username)
  71                args.add ('--passwo rd')
  72                args.add (password)
  73           } 
  74           pr intln "Exe cuting wit h argument s: ${args} "
  75           cl i.execute( args, inpu t, output,  err)
  76           cl i.close()
  77       }
  78  
  79       def cr eateJob(Jo b job){
  80           pr intln "cre ating job  ${job.name } in jenki ns ${jenki nsBaseUrl} "
  81           Fi leInputStr eam config FileInputS tream = ne w FileInpu tStream(jo b.configFi le)
  82           ru nCliComman d(['create -job', job .name], co nfigFileIn putStream)
  83       }
  84  
  85       def up dateJob(Jo b job){
  86           de f reenable Job = isJo bEnabled(j ob.name)
  87           pr intln "upd ating job  ${job.name } in jenki ns ${jenki nsBaseUrl} "
  88           Fi leInputStr eam config FileInputS tream = ne w FileInpu tStream(jo b.configFi le)
  89           ru nCliComman d(['update -job', job .name], co nfigFileIn putStream)
  90           if  (reenable Job) {
  91                println  "re-enabli ng job ${j ob.name} i n jenkins  ${jenkinsB aseUrl}"
  92                runCliCo mmand(['en able-job',  job.name] )
  93           }
  94       }
  95  
  96       def bo olean does JobExist(S tring jobN ame)  {
  97           de f slurper  = new XmlS lurper()
  98           de f addr        = "$jen kinsBaseUr l/api/xml"
  99           de f authStri ng = "${us ername}:${ password}" .getBytes( ).encodeBa se64().toS tring()
  100           de f conn = a ddr.toURL( ).openConn ection()
  101           co nn.setRequ estPropert y( "Author ization",  "Basic ${a uthString} " )
  102  
  103           // def jenkin sMain = sl urper.pars e("$jenkin sBaseUrl/a pi/xml")
  104           de f jenkinsM ain = slur per.parseT ext( conn. content.te xt )
  105  
  106           bo olean foun d = false
  107           je nkinsMain. job.each{
  108                if (it.n ame.text()  == jobNam e) {
  109                    foun d = true
  110                }
  111           }
  112  
  113           re turn found
  114       }
  115  
  116       def bo olean isJo bEnabled(S tring jobN ame)  {
  117           de f slurper  = new XmlS lurper()
  118           de f addr        = "$jen kinsBaseUr l/job/$job Name/confi g.xml"
  119           de f authStri ng = "${us ername}:${ password}" .getBytes( ).encodeBa se64().toS tring()
  120           de f conn = a ddr.toURL( ).openConn ection()
  121           co nn.setRequ estPropert y( "Author ization",  "Basic ${a uthString} " )
  122  
  123           // def jobCon fig = slur per.parse( "$jenkinsB aseUrl/job /$jobName/ config.xml ")
  124           de f jobConfi g = slurpe r.parseTex t( conn.co ntent.text  )
  125  
  126           bo olean enab led = fals e
  127           if  (jobConfi g.disabled  == 'false ') {
  128              enabled =  true
  129           }
  130           re turn enabl ed
  131       }
  132  
  133       @GrabR esolver(na me = "nexu s", root =  "https:// store.vist acore.us/n exus/conte nt/groups/ public")
  134       @Grab( 'hr.helix: kin:1.0')
  135       def Li st<Job> bu ildJobConf ig(String  kinBuildFi lePath) {
  136           pr intln "pro cessing $k inBuildFil ePath"
  137           hr .helix.kin .IO io = n ew hr.heli x.kin.IO()
  138           hr .helix.kin .script.Ru nner runne r = new hr .helix.kin .script.Ru nner()
  139           Si mpleTempla teEngine e ngine = ne w groovy.t ext.Simple TemplateEn gine()
  140           St ring dsl =  new File( kinBuildFi lePath).ge tText().re place('%br anch%', gi tBranch)
  141  
  142           de f build =  runner.run (dsl)
  143           de f jobs = n ew ArrayLi st<Job>()
  144           bu ild.produc ers().each  { job ->
  145                def name  = job.nam e
  146                def temp lates = bu ild.templa tes(name)
  147                def temp late = fin dValidTemp late(kinBu ildFilePat h, templat es)
  148                if (!tem plate) {
  149                    Syst em.err.pri ntln "No t emplate $t emplates f or job '$n ame'!"
  150                    Syst em.exit 4
  151                }
  152  
  153                def trai ts = build .traits(na me)
  154                def conf ig = engin e.createTe mplate(tem plate).mak e(traits)
  155  
  156                def conf igFile = n ew File("$ workspaceD ir/build/$ name/confi g.xml")
  157                io.write Config con fig, confi gFile
  158                println  "creating  ${configFi le.absolut ePath}"
  159                jobs.add (new Job(n ame: name,  configFil e: configF ile))
  160           }
  161  
  162           re turn jobs
  163       }
  164  
  165       File f indValidTe mplate(Str ing kinBui ldFilePath , List<Str ing> templ ateNames)  {
  166  
  167           te mplateName s.findResu lt { name  ->
  168                def temp latePath =  new File( kinBuildFi lePath).pa rent + '/'  + name
  169                println  "looking f or templat e here: $t emplatePat h"
  170                def temp late = new  File(temp latePath)
  171                template .isFile()  ? template  : null
  172           }
  173       }
  174  
  175   }