user1559263
user1559263

Reputation: 83

Jenkins pipeline shared library - passing arguments

I am trying to build a function that accepts parameters to override defaults but I keep getting "null".

I have written a simple function:

// vars/Run.groovy
def test(String type, String parallel = 'yes') {
    println(type)
    println(parallel)
}

My pipeline looks like this:

node('master') {
    Run.test('unit')
    Run.test('unit', parallel = 'no')
}

The result I get is:

unit
yes

unit
null

What am I missing?

Upvotes: 5

Views: 3595

Answers (1)

Fidel
Fidel

Reputation: 1037

You just have to pass the value. This will override your default value.

Run.test('unit', 'no')

Upvotes: 5

Related Questions