Skip to content Skip to sidebar Skip to footer

How I Pass Params From Jenkins To Build.gradle?

I want to pass value to my build.gradle file through jenkins (build with params). I have a String and I need to use this String params to make my release ?

Solution 1:

Parametrized builds provide those parameters as environmental variables, like $PARAM_NAME. Use your favorites gradle method of getting environmental variables, like System.getenv('PARAM_NAME') or environmentString = "$System.env.PARAM_NAME"

Solution 2:

You can use the plugin This build is Parameterized and select string Parameter int that. In this you can define parameter name and value. Suppose PARA is your parameter name and value is its default value, then you can pass this value to build.gradle as $PARA. For more details see https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Build.

Solution 3:

In General configuration set "This project is parameterized" checkbox to true, and set String/stash/choice/int parameter as you wish for , the name field is your variable name. In your dev project , in the gradle file just grab this variable by calling simple getEnv method.

String inputFromJenkins = System.getenv('VARIABLE_NAME')
println('VARIABLE_NAME = ' + inputFromJenkins)

for extra documentation: gradle env variables documentation

Post a Comment for "How I Pass Params From Jenkins To Build.gradle?"