Jenkins get/set data external to job -


does jenkins have way set global properties job? have many such needs - - have number of slaves, across unix , windows, , various different permissions locations - it's not easy have connected file system. have various levels of maturity promote through - instance, want promote build number uat - , promote whatever number in uat training , on. - really, in "release uat" - want store idea of build number released - , read "release training" job. @ moment hacking restricting them run same slave, , writing file, not ideal.

i may not have totally understood question can perform lot of work built in groovy scripting function in jenkins, including reading parameters other jobs, , rewriting or initializing parameters in current job. can use parameters record information can retrieved on demand other jobs

for instance can find build number of last successful build of project:

import hudson.model.* def hif = hudson.instance  def = hif.getitems(hudson.model.project).find{it.displayname.touppercase()=='my_projectname'}.getbuilds().findall{it.result==result.success }.first() out.println a.number //build number out.println a.buildvariableresolver.resolve('somevariable')// parameter used call 

(you include other criteria @ point)

if want save information parameter can later read bulid step or job first create parameter in job config, write in code so:

import hudson.model.* def hif = hudson.instance def buildmap = build.getbuildvariables()   buildmap['myspecialvar']='somevalue'  setbuildparameters(buildmap)  def setbuildparameters(map) {     def npl = new arraylist<stringparametervalue>()     (e in map) {         npl.add(new stringparametervalue(e.key.tostring(), e.value.tostring()))     }     def newpa = null     def oldpa = build.getaction(parametersaction.class)     if (oldpa != null) {         build.actions.remove(oldpa)         newpa = oldpa.createupdated(npl)     } else {         newpa = new parametersaction(npl)     }     build.actions.add(newpa) } 

combining these techniques instance:

  1. save bunch of information 'output parameters' in job one
  2. find recent successful instance of job 1 , read parameters
  3. if necessary save parameters job2's parameter list accessible other build steps.

or

if happy use files may able use archive plugin, write file , archive post build action. file saved master, , use 'copy artifacts project' option in second build retrieve file. can use parameter filters , techniques above pick right build.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -