I have an Azure release pipeline that triggers a Salesforce Sandbox deployment when a developer pushes a commit to a dev branch(connected to the pipeline). Sometimes, this deployment fails, which also causes the release pipeline to fail. Currently, the developers do not receive a notification when this happens.
Is there a way to push a comment to the commit to notify the developer when their commits are causing issues on the dev sandbox?
You can add a new job in your release pipeline to add comments to the commit using GitHub REST API Create a commit comment when the deployment job is failed.
Add a new agent job after your deployment job.
Add a Command line task to run Github REST API to add comments to your commit.
COMMIT_ID=$(Release.Artifacts.{SourceAlias}.SourceVersion)
echo $COMMIT_ID
curl -L \
-X POST \
"https://api.github.com/repos/{GitHubOwner}/{GitHubRepoName}/commits/$COMMIT_ID/comments" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token $(GitHub.Token)" \
-d '{"body":"The deployment is failed."}'
When the deployment is successful, the "Check Deploy" job will be skipped. When the deployment is failed, the "Check Deploy" job will add a comment to the commit that triggered the Azure release pipeline.