Open langri-sha opened 4 years ago
Looks like something is wrong with filters here, so cloudbuild SDK returns empty list for ongoing builds.
Probably API was changed since then, and branch name is now available in Source.RepoSource.Revision.BranchName
property:
https://cloud.google.com/cloud-build/docs/configuring-builds/substitute-variable-values#using_default_substitutions
Also this will not work with GitHub App builds (because they in fact are sourced from storage bucket).
I am using simple bash script instead of cancelot to cancel previous cloud builds, it bypasses those issues. Also it fetches target branch from current build id and works for Github-sourced builds (filtering by substitutions.BRANCH_NAME
).
Adapted version to mimic cancelot args is here: https://gist.github.com/siberex/bb0540b208019382d08732cc6dd59007
Usage:
steps:
- id: 'cancel previous builds'
name: 'gcr.io/cloud-builders/gcloud-slim:latest'
entrypoint: 'bash'
args: ['path/to/cancelot.sh', '--current_build_id', '$BUILD_ID', '--same_trigger_only']
Is this still a problem?
yes, it still does not work.
Does your cloud build trigger configured in global
region?
Otherwise such builders as slackbot, cancelot could not see information about your build
Affected builder image
gcr.io/cloud-builders-community/cancelot
Expected Behavior
Cancelot should be cancelling running builds.
Actual Behavior
The filters are not matching any running builds, even though some are currently in progress.
Steps to Reproduce the Problem
WORKING
Additional Info
Step output for initial build:
Step output for subsequent build: