spring-bootcloud-foundrycloudfoundry-uaasap-cloud-foundry

Passing 'program arguments' to cf run-task in CloudFoundry


I have deployed a Spring-boot app for a task/job in PCF. I can also able to tigger the 'main' method of the springboot app using below command .

cf run-task APP-NAME "$PWD/.java-buildpack/oracle_jre/bin/java 
org.springframework.boot.loader.JarLauncher"

But I would like to pass 'programme arguments' as we pass in IntelliJ IDE , so that I can get that value in args of main method.

public static void main(String[] args)

expecting a command like ,

cf run-task APP-NAME "$PWD/.java-buildpack/oracle_jre/bin/java 
org.springframework.boot.loader.JarLauncher --arg0=value0 --arg1=value1"

Please let me know if you came across this use-cases.Thanks in Advance !


Solution

  • You can define parameters for your program with:

    cf set-env APP-NAME arg0 value0 arg1 value1

    Best practice ask to restage your app after that:

    cf restage APP-NAME

    Now you can run your program as usual:

    cf run-task APP-NAME "$PWD/.java-buildpack/oracle_jre/bin/java org.springframework.boot.loader.JarLauncher"