Sunday, March 26, 2017

Dynamic parameter based on previous string parameter

Leave a Comment

In Jenkins I have a string parameter HOST. After this parameter I have a dynamic parameter URL. This parameter needs to be a concatenation of strings, including the previously defined HOST parameter.

I have been unable to find out how to do this.

The motivation for this is subsequent parameters will also use this HOST parameter.

2 Answers

Answers 1

Just make sure I understand your requirement correctly: you have two parameters and the later one is depends on the value of the first one?

If it's so I think plugin Parameterized Build is enough for this:

  • Job configuration:

parameter definition enter image description here

  • Build with specified value:

Build with specified value

  • Build result:

Build result

  • If you change your HOST value at build, the URL will also changed.

Hope this helps :-)

Answers 2

The dynamic parameter plugin might not be the right choice for your task. If you want the URL parameter to be updated according to the changes in the HOST parameter, you should consider using the Active Choices Plugin.

In your case, create a String parameter for the host, and an active choice reactive parameter for the url. this parameter reads the host and updates the url. example:

enter image description here

(you can find another example here: http://stackoverflow.com/a/42871619/947784)

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment