Status in VCS of Discarded runs

Workaround
Notification Policy + Webhook (recommended workaround) You can use a Spacelift notification policy with a webhook to override the commit status when a run is discarded. The approach: Create a named webhook endpoint in Spacelift that points to your Bitbucket Server's build status API Write a notification policy that fires when run.state == "DISCARDED" and POSTs a corrected status (CANCELLED) to Bitbucket, overwriting the FAILED status Spacelift already sent Example policy (Rego v1): rego package spacelift webhook contains wbdata if { some endpoint in input.webhook_endpoints endpoint.id == "bitbucket-build-status" run := input.run_updated.run run.state == "DISCARDED" stack := input.run_updated.stack wbdata := { "endpoint_id": endpoint.id, "payload": { "key": sprintf("spacelift/%s/%s", [stack.id, run.type]), "state": "CANCELLED", "url": sprintf("https://your-spacelift-account.app.spacelift.io/stack/%s/run/%s", [stack.id, run.id]), "name": sprintf("Spacelift - %s (discarded)", [stack.name]), "description": "Run was discarded by user", }, "method": "POST", } } The webhook endpoint URL in Spacelift would be: https://your-stash-instance/rest/api/latest/projects/{projectKey}/repos/{repoSlug}/commits/{commitHash}/builds The tricky part here is that the commit hash is available in the policy input (input.run_updated.run.commit.hash) but you can't dynamically construct the webhook endpoint URL per-request β€” the endpoint is static. To work around this, you'd need a lightweight intermediary (a Lambda, a simple proxy, or a Bitbucket plugin) that receives the webhook from Spacelift, extracts the commit hash from the payload, and forwards the build status to the correct Bitbucket API path.
Problem
The status of discarded stack runs show as failed in VCS.

Please authenticate to join the conversation.

Upvoters
Status

πŸ‘€ In Review

Board

πŸ’‘ Feature Requests

Tags

Integrations

Date

1 day ago

Subscribe to post

Get notified by email when there are changes.