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?
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.
If you are using an IDE, go to run, edit configurations, gradle, select gradle task and update the environment variables.
The global properties file should be located in your home directory: On Windows: C:\Users\<you>\. gradle\gradle. properties.
Use -Pmyprop
instead of -Dmyprop
.
The Gradle Jenkins Plugin accepts parameters with -P
.
-D
is for java parameters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With