Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass a system property to gradle with the jenkins gradle plugin?

I have a gradle tasks that deploys some stuff to bintray using curl.

For this to work it needs my bintray api key. I don't want to put that in my build script (or a property file) since all this stuff is hosted in plain sight at github.

Instead I made the task use a property named bintrayApikey which is to be provided when calling gradle. When I run it locally using

gradlew pushToBintray -DbintrayApikey=<my api key>

everything works as intended.

So the next step is to make this work from my Jenkins over at cloudbees. Since there doesn't seem to be a special place for putting system properties I just added them to the tasks, but this does not seem to work. In the console I can see it is accessing bintray all right, but then finishes with:

This resource requires authentication 

So how can I provide the property value in my jenkins job configuration?

like image 703
Jens Schauder Avatar asked Apr 03 '13 08:04

Jens Schauder


People also ask

How do I pass system properties to Gradle build?

Using the -D command-line option, you can pass a system property to the JVM which runs Gradle. The -D option of the gradle command has the same effect as the -D option of the java command. You can also set system properties in gradle. properties files with the prefix systemProp.

How do I pass environment variables in Gradle task?

If you are using an IDE, go to run, edit configurations, gradle, select gradle task and update the environment variables.

Where are Gradle Gradle properties?

The global properties file should be located in your home directory: On Windows: C:\Users\<you>\. gradle\gradle. properties.


1 Answers

Use -Pmyprop instead of -Dmyprop.

The Gradle Jenkins Plugin accepts parameters with -P.

-D is for java parameters.

like image 148
Cengiz Avatar answered Oct 25 '22 16:10

Cengiz