How to access parameters in a Parameterized Build?

Vizionz picture Vizionz · Feb 17, 2015 · Viewed 181.7k times · Source

How do you access parameters set in the "This build is parameterized" section of a "Workflow" Jenkins job?

TEST CASE

  1. Create a WORKFLOW job.
  2. Enable "This build is parameterized".
  3. Add a STRING PARAMETER foo with default value bar text.
  4. Add the code below to Workflow Script:

    node()
    {
         print "DEBUG: parameter foo = ${env.foo}"
    }
    
  5. Run job.

RESULT

DEBUG: parameter foo = null

Answer

Nick picture Nick · Mar 27, 2015

I think the variable is available directly, rather than through env, when using Workflow plugin. Try:

node()
{
    print "DEBUG: parameter foo = ${foo}"
}