2

I run my java main program with args using gradle application plugin's run task. The program uses picocli to parse command line args. This works fine when run in my Dev environment using following command:

./gradlew  run --args="-ahttp://foo.com/bar -dmydeviceid"

It also runs fine when I ssh into a docker container for my apps docker image.

However, if I run the same Gradle run task in Spinnaker pipeline Run Job stage with same docker image it does not work. Log statements show that arguments are received by program correctly but are not processed by picocli. I am guessing it is because the code generator for picocli is not running in the Run Job of Spinnaker pipeline for some reason.

Any suggestions how to fix this.

Farrukh Najmi
  • 5,055
  • 3
  • 35
  • 54
  • I’m glad you found a workaround. If you’re still interested in investigating the underlying cause I’d be happy to help. Can you share the log statements you mentioned that show args are received by the program but not processed by picocli? Also, did you have a chance to run with the `-Dpicocli.trace=DEBUG` system property? – Remko Popma Jan 27 '19 at 21:36

1 Answers1

1

I have found a workaround. Instead of running the program using 'gradle run', I created a shellscript that uses the distribution tar for the program produced by gradle application plugin.

Here is what the script looks like:

#!/usr/bin/env bash

# Build application tar
gradle -i distTar

tar -xvf ./build/distributions/apk-deployer-cli.tar

./apk-deployer-cli/bin/apk-deployer-cli -a $APK_URL -d $DEVICE_ID

Then in spinnaker stage config I set the $APK_URL and $DEVICE_ID as part of the env vars for the stage as follows:

      "envVars": [
        {
          "name": "APK_URL",
          "value": "${parameters[\"APK_URL\"]}"
        },
        {
          "name": "DEVICE_ID",
          "value": "${parameters[\"DEVICE_ID\"]}"
        }
      ]
Farrukh Najmi
  • 5,055
  • 3
  • 35
  • 54