It’s time for some good jq magic. I need to know where a specific release is deployed in the current environment. I also need to know which version of that release is deployed in each spot. Specifically, I’m checking for shield
, but you can change RELEASE_NAME
to whatever you want.
export BOSH_ENVIRONMENT=my-bosh-directorexport RELEASE_NAME=shield
bosh deployments --json | jq '[.Tables[].Rows[] | select(.release_s | contains(env.RELEASE_NAME)) | {name: .name, version: .release_s | capture(".*"+env.RELEASE_NAME+"/(?<v>[0-9.]+)").v}]'
This outputs some delicious, nutritious JSON:
[
{
"name": "my-concourse",
"version": "8.3.0"
},
{
"name": "my-minio",
"version": "8.3.0"
},
{
"name": "my-prometheus",
"version": "8.3.0"
},
{
"name": "my-shield",
"version": "8.3.0"
},
{
"name": "my-vault",
"version": "8.3.0"
},
{
"name": "my-bosh-1",
"version": "8.2.1"
},
{
"name": "my-bosh-2",
"version": "8.3.0"
},
{
"name": "my-bosh-3",
"version": "8.3.0"
}
]
This saved me time. I took the time I saved and I wrote this blog post to save you time. That’s basically charity. Tax deductible. Pay it forward. Good work everyone.