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

Jens Schauder picture Jens Schauder · Apr 3, 2013 · Viewed 8.9k times · Source

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?

Answer

Cengiz picture Cengiz · Apr 5, 2013

Use -Pmyprop instead of -Dmyprop.

The Gradle Jenkins Plugin accepts parameters with -P.

-D is for java parameters.