user2495833
user2495833

Reputation: 3

How to get routes from the specific app in pcf command?

the below commands provides all the information for that application. how to get the routes and store into variable.

cf app app-name

name: Example requested state: started routes: route1,route2 stack: cflinuxfs2 buildpacks: Javabuildpack40

how to read and store into variable to use further in the jenkins job

Upvotes: 0

Views: 2901

Answers (2)

Daniel Mikusa
Daniel Mikusa

Reputation: 15051

You could use cf app <app-name> | grep 'routes:' | cut -d ':' -f 2 | xargs.

This will filter out all lines except the line displaying your routes, trim off the leading routes: (cut) and whitespace (xargs).

If you want it in a variable, run MY_ROUTES=$(cf app <app-name> | grep 'routes:' | cut -d ':' -f 2 | xargs). This will result in a comma separated list of routes in the variable.

Ex: route1.example.com, route2.example.com, route3.example.com.

You could pick out a specific route by using echo $MY_ROUTES | cut -d ',' -f <num> where <num> is the number of the route you want (eg. 1 is route1.example.com, 2 is route2.example.com and 3 is route3.example.com).

Hope that helps!

Upvotes: 1

Arun
Arun

Reputation: 3680

Write a Shell Script to execute

cf app APP_NAME

And then read the output. Writing a Wrapper script around CF-CLI commands is the wise way to deal this

Upvotes: 0

Related Questions