SalesforceCommerceCloud / sfcc-ci

Salesforce Commerce Cloud CLI
https://npmjs.com/package/sfcc-ci
BSD 3-Clause "New" or "Revised" License
229 stars 91 forks source link

sandbox:create returning json multiple times #178

Open jlbruno opened 4 years ago

jlbruno commented 4 years ago

Running the sandbox:create command and looking at the json being returned - it seems to be returning the json 3 times for the 1 sandbox creation.

sfcc-ci sandbox:create -r xxxx -t 1 -j -s

Here's what I see returned this morning - edited to remove realm data and sb id, but the sb ID was the same.


{"message":"Creation of new sandbox 002 for realm xxxx finished (300504 ms). Sandbox id is f91f5ccd-036c-4969-9a91-11118ca78e11, status of sandbox is started. You may use `sfcc-ci sandbox:list` to check the status of the sandbox.","sandbox":{"id":"f91f5ccd-036c-4969-9a91-11111ca78e11","realm":"xxxx","instance":"002","versions":{"app":"20.9.1.23","web":"20.2.1.0"},"state":"started","createdAt":"2020-09-03T13:25:33Z","eol":"2020-09-03T14:25:22Z","links":{"bm":"https://xxxx-002.sandbox.us01.dx.commercecloud.salesforce.com/on/demandware.store/Sites-Site","ocapi":"https://xxxx-002.sandbox.us01.dx.commercecloud.salesforce.com/s/-/dw/data/","impex":"https://xxxx-002.sandbox.us01.dx.commercecloud.salesforce.com/on/demandware.servlet/webdav/Sites/Impex","code":"https://xxxx-002.sandbox.us01.dx.commercecloud.salesforce.com/on/demandware.servlet/webdav/Sites/Cartridges","logs":"https://xxxx-002.sandbox.us01.dx.commercecloud.salesforce.com/on/demandware.servlet/webdav/Sites/Logs"}},"instance":{"host":"xxxx-002.sandbox.us01.dx.commercecloud.salesforce.com","alias":"xxxx-002","default":true}}
{"message":"Creation of new sandbox 002 for realm xxxx finished (305498 ms). Sandbox id is f91f5ccd-036c-4969-9a91-11118ca78e11, status of sandbox is started. You may use `sfcc-ci sandbox:list` to check the status of the sandbox.","sandbox":{"id":"f91f5ccd-036c-4969-9a91-11111ca78e11","realm":"xxxx","instance":"002","versions":{"app":"20.9.1.23","web":"20.2.1.0"},"state":"started","createdAt":"2020-09-03T13:25:33Z","eol":"2020-09-03T14:25:22Z","links":{"bm":"https://xxxx-002.sandbox.us01.dx.commercecloud.salesforce.com/on/demandware.store/Sites-Site","ocapi":"https://xxxx-002.sandbox.us01.dx.commercecloud.salesforce.com/s/-/dw/data/","impex":"https://xxxx-002.sandbox.us01.dx.commercecloud.salesforce.com/on/demandware.servlet/webdav/Sites/Impex","code":"https://xxxx-002.sandbox.us01.dx.commercecloud.salesforce.com/on/demandware.servlet/webdav/Sites/Cartridges","logs":"https://xxxx-002.sandbox.us01.dx.commercecloud.salesforce.com/on/demandware.servlet/webdav/Sites/Logs"}},"instance":{"host":"xxxx-002.sandbox.us01.dx.commercecloud.salesforce.com","alias":"xxxx-002","default":true}}
astound-ci commented 4 years ago

@tobiaslohr same behaviour here... --sync option passed cause resulting JSON output to be invalid.

wundrian commented 4 years ago

Does this also happen without the --json option set? I'm looking at the code, but the loop's pretty solid and hasn't changed in months. I'm a bit irritated why this would start now.

astound-ci commented 4 years ago

@wundrian , yes it happens always whenever --sync option passed. ./sfcc-ci-macos sandbox:create --sync --realm zzrk --ttl 1 Creation of new sandbox 009 for realm zzrk finished (288037 ms). Sandbox id is b56049c6-4745-4abc-9fa3-a74d9acf9481, status of sandbox is started. You may usesfcc-ci sandbox:listto check the status of the sandbox. Creation of new sandbox 009 for realm zzrk finished (288236 ms). Sandbox id is b56049c6-4745-4abc-9fa3-a74d9acf9481, status of sandbox is started. You may usesfcc-ci sandbox:listto check the status of the sandbox. Creation of new sandbox 009 for realm zzrk finished (298174 ms). Sandbox id is b56049c6-4745-4abc-9fa3-a74d9acf9481, status of sandbox is started. You may usesfcc-ci sandbox:listto check the status of the sandbox.

EvilJordan commented 3 years ago

The easiest solution, since I assume you're piping it through jq is to "slurp" all responses into an array, then process only the first element:

... | jq -s '.[0].key' -s is for slurp

tobiaslohr commented 3 years ago

@jlbruno @astound-ci Is this issue still existing?

jlbruno commented 3 years ago

@tobiaslohr I unfortunately am not able to test this at this time. @astound-ci can you help?