Pass dynamic parameters to Gradle Jenkins plugin

I am using the Gradle Jenkins plugin to create a Jenkins Job that executes a Gradle build. I have a couple of parameters that are always required and these are passed to a Jenkins “Parameterized build”. These parameters are correctly passed to gradlew.bat with the following format:

Now there are some additional parameters that are dynamic in nature and I’d prefer to use a single Jenkins parameter such as “AdditionalParamters” and pass these values like so:

“-DoptionalParam1=value1 -DOptionalParam2=value2”.
If I use such a parameter, then the value passed to Gradle is “-DAdditionalParamters=-DoptionalParam1=value1 -DOptionalParam2=value2” and this is not what I’d intended to pass.

So are there any means of passing multiple System parameters to gradle by using a single Jenkins parameter?


we have a simular situation with optional parameters. However, the parameters you want to transport from the Jenkins job to Gradle are not JVM parameters ("-D"), but Gradle parameters. There you have to use “-P”. Within the Jenkins configuration page in section “Invoke Gradle script” there is the “Switches” textbox. Here you define “-PParam1=${VALUE) -PParam2=${VALUE_2}” (in case these VALUES are know to Jenkins).

In my Gradle script I’m invoking a Java application through JavaExec. The parameters I pass from Jenkins are passed on to the Java application through -D ( JVM system properties ) hence they need to be passed on as JVM parameters