Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sf project deploy validate --json to include the deploymentId in the output json object for further processing #2312

Closed
diegocomi opened this issue Jul 15, 2023 · 5 comments
Labels
feature Issue or pull request for a new feature

Comments

@diegocomi
Copy link

Is your feature request related to a problem? Please describe.
When running sf cli in Github actions, I would like sf project deploy validate --json to return a more easily machine readable deploymentId, so I can run further processing (e.g. sf project deploy report) on it in GHA failure steps.

What are you trying to do
My developers use github actions as our CI/CD system for Salesforce. We are trying to run a deployment validation on PR sync, and then a quick deploy on merge to main to reduce our github billable time. We want to run sf project deploy validate and capture the deployment Id from the result in a machine-readable format (json).

This works fine when the validation is a success, as the json output includes a clear Id property that we can use for further processing. But when the validation is not successful, the format of the json is as follows:

{
  "code": 1,
  "context": "DeployMetadataValidate",
  "commandName": "DeployMetadataValidate",
  "message": "Failed to validate the deployment (0Af1n00001if15hCAA). Due To:\nAverage test coverage across all Apex Classes and Triggers is 52%, at least 75% test coverage is required.",
  "name": "FailedValidationError",
  "status": 1,
  "stack": "FailedValidationError: Failed to validate the deployment (0Af1n00001if15hCAA).....[redacted[",
  "exitCode": 1,
  "warnings": []
}

meaning that if I want to follow up with a failure step to retrieve a sf project deploy report in a different format, I can only grab the deployment Id from the message property, which is subject to changes in formatting.

Describe the solution you'd like
When I run sf project deploy validate with the --json flag and the validation fails
I want the output json object to contain a stably named property (id or deploymentId)
So that I can read that property from the json object reliably and use it for further processing

Describe alternatives you've considered
Right now we are reading the deployment Id from the message property, but this is a string error message whose format has changed through the years, so it's not massively reliable.

@diegocomi diegocomi added the feature Issue or pull request for a new feature label Jul 15, 2023
@github-actions
Copy link

Thank you for filing this feature request. We appreciate your feedback and will review the feature at our next grooming or sprint planning session. We prioritize feature requests with more upvotes and comments.

@git2gus
Copy link

git2gus bot commented Jul 15, 2023

This issue has been linked to a new work item: W-13765229

@mshanemc
Copy link
Contributor

good call. SfError lets us add a data property under the json output where we can provide this value for you.

@mshanemc
Copy link
Contributor

should be in the nightly tag/channel now (which becomes rc later today) if you want to try it

@diegocomi
Copy link
Author

image
@mshanemc thank you so much for this, and for the amazing speed of it. All works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Issue or pull request for a new feature
Projects
None yet
Development

No branches or pull requests

2 participants