You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need to ensure that we only cancel the pipeline run that is running
on the same branch as the current PR or push event. This ensures that we
don't cancel the wrong pipeline run.
On PullRequest events, we only cancel the pipeline run that is running
on the same Pull Request number.
On Push events, we only cancel the pipeline run that is running on the
same SourceBranch (which is the same as HeadBranch on push)
This avoids the issue when you have multiple pull request running on a
repo and we don't cancel the wrong ones that are running for a different
PR.
Signed-off-by: Chmouel Boudjnah <[email protected]>
ifsourceBranch, ok:=pr.GetAnnotations()[keys.SourceBranch]; ok {
73
+
// NOTE(chmouel): Every PR has their own branch and so is every push to different branch
74
+
// it means we only cancel pipelinerun of the same name that runs to
75
+
// the unique branch. Note: HeadBranch is the branch from where the PR
76
+
// comes from in git jargon.
77
+
ifsourceBranch!=p.event.HeadBranch {
78
+
p.logger.Infof("cancel-in-progress: skipping pipelinerun %v/%v as it is not from the same branch, annotation source-branch: %s event headbranch: %s", pr.GetNamespace(), pr.GetName(), sourceBranch, p.event.HeadBranch)
79
+
continue
80
+
}
81
+
}
82
+
83
+
ifpr.IsPending() {
84
+
p.logger.Infof("cancel-in-progress: skipping pipelinerun %v/%v as it is pending", pr.GetNamespace(), pr.GetName())
85
+
}
86
+
65
87
ifpr.IsDone() {
88
+
p.logger.Infof("cancel-in-progress: skipping pipelinerun %v/%v as it is done", pr.GetNamespace(), pr.GetName())
0 commit comments