CloudFoundry: Determining buildpack used by application

The “cf app” command will provide a brief expansion of a buildpack’s settings, but does not provide an exact buildpack name.  Luckily, this can easily be pulled using “cf curl” and the CloudFoundry API.

Assuming you have the jq utility for parsing/querying json output:

# set name of cloudfoundry app
app="my-cf-app"

# using name, pull cf app guid
guid=$(cf app $app --guid)

# using app guid, get buildpack guid
bpackguid=$(cf curl /v2/apps/$guid/summary | jq .detected_buildpack_guid | tr -d '"')

# using buildpack guid, get buildpack name
bpackname=$(cf curl /v2/buildpacks/$bpackguid | jq .entity.name | tr -d '"')
echo "buildpack used by $app name = $bpackname"

Here is a link to my bash script on github.

 

REFERENCES

stackoverflow, using cf curl to list buildpacks

stackoverflow, cf curl for org space

cf docs, lock unlock buildpack

stackoverflow, apps and buildpacks in cf

cf docs, cf curl

jq utility