Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 361
user1559263 Avatar asked Jun 23 '17 13:06

user1559263


1 Answers

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

Run.test('unit', 'no')
like image 129
Fidel Avatar answered Sep 20 '22 16:09

Fidel