0

Can I use sfdx or some other tool to find out salesforce release version in the org using a script?

Ideally I would like to iterate over all of my sandboxes and find out which Salesforce release they are using.

1 Answer 1

2

We can use the following combination of sfdx, sh, jq and curl script to get the information about the Salesforce release version on a specific org

at=$(sfdx force:org:display --json | jq '.result.accessToken' | tr -d '"')
iu=$(sfdx force:org:display --json | jq '.result.instanceUrl' | tr -d '"')
namespace=$(cat sfdx-project.json | jq '.namespace' -r)
iu="$iu/services/data"
curl $iu -H 'Authorization: Bearer '$at'' -H 'X-PrettyPrint:1' > data.json
echo $(cat data.json) | jq '.[length-1].label' -r
echo $(cat data.json) | jq '.[length-1].version' -r

This will provide the following results:

./scripts/getVersion.sh                            
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2326    0  2326    0     0   4175      0 --:--:-- --:--:-- --:--:--  4175
Spring '23
57.0

To get the information of Salesforce version for a list of sandboxes, a following script can be used:

echo "Org,Label,Version" >> versions.csv
for org in qa3 qa0
do
    echo "Org is $org"
    sfdx config:set defaultusername=$org
    ./scripts/getVersion.sh
    label=$(echo $(cat data.json) | jq '.[length-1].label' -r)
    version=$(echo $(cat data.json) | jq '.[length-1].version' -r)
    echo "$org,$label,$version" >> versions.csv
done

You may include more items in the loop, more organizations both productions, sandboxes and developer edition orgs and in the end the file versions.csv will include the versions of all the orgs

Org,Label,Version
qa3,Spring '23,57.0
qa0,Spring '23,57.0
qa1,Spring '23,57.0
qa2,Spring '23,57.0
qa4,Spring '23,57.0
reg0,Spring '23,57.0
reg1,Spring '23,57.0
reg2,Spring '23,57.0
d0,Spring '23,57.0
h0,Spring '23,57.0
n0,Spring '23,57.0
dev,Spring '23,57.0
b,Winter '23,56.0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .