Retrieve all jenkins parameters to iterate in groovy code -


based on this answer, iterate on properties in jenkins job , replace value in job in build step.

e..g.

file = new file("folder/path/myfile.cs") filetext = file.text; filetext = filetext.replaceall("parameter", "parametervalue"); file.write(filetext); 

i saw example resolve 1 param this:

build.buildvariableresolver.resolve("myparameter") 

but need

  1. to iterate on of them
  2. to in build step (after pulling source code) in current build.

how can it?

the following sample groovy code can use scriptler plugin, suggest use. code can correctly read environment variables set in jenkins job:

import jenkins.model.jenkins  def thr = thread.currentthread() def build = thr?.executable def env = build.getenvironment() def buildnumber = env.get("build_number") 

in case want read build parameters (you have parameterized build , need access variables), need use previous code , add following:

def bparams = build.getbuildvariables() def mybuildparam = bparams.get("my_build_parameter") 

after read them, can write them file, in build step occurring after git cloning.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -