From 687d57217d99dee9f97e282dd2eed776f6f5da89 Mon Sep 17 00:00:00 2001 From: qwerty287 <80460567+qwerty287@users.noreply.github.com> Date: Mon, 16 May 2022 20:04:00 +0200 Subject: [PATCH] Fix branch condition on tags (#917) * Fix branch condition on tags * Add docs * Update docs/docs/20-usage/20-pipeline-syntax.md Co-authored-by: Anbraten --- docs/docs/20-usage/20-pipeline-syntax.md | 4 ++++ pipeline/frontend/yaml/constraint/constraint.go | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/docs/20-usage/20-pipeline-syntax.md b/docs/docs/20-usage/20-pipeline-syntax.md index 78836031d..2db15f0b4 100644 --- a/docs/docs/20-usage/20-pipeline-syntax.md +++ b/docs/docs/20-usage/20-pipeline-syntax.md @@ -302,6 +302,10 @@ Example conditional execution by repository: #### `branch` +:::note +Branch conditions are not applied to tags. +::: + Example conditional execution by branch: ```diff diff --git a/pipeline/frontend/yaml/constraint/constraint.go b/pipeline/frontend/yaml/constraint/constraint.go index 64305d926..54af231c6 100644 --- a/pipeline/frontend/yaml/constraint/constraint.go +++ b/pipeline/frontend/yaml/constraint/constraint.go @@ -53,7 +53,6 @@ func (c *Constraints) Match(metadata frontend.Metadata) bool { match := c.Platform.Match(metadata.Sys.Arch) && c.Environment.Match(metadata.Curr.Target) && c.Event.Match(metadata.Curr.Event) && - c.Branch.Match(metadata.Curr.Commit.Branch) && c.Repo.Match(metadata.Repo.Name) && c.Ref.Match(metadata.Curr.Commit.Ref) && c.Instance.Match(metadata.Sys.Host) && @@ -63,6 +62,9 @@ func (c *Constraints) Match(metadata frontend.Metadata) bool { if metadata.Curr.Event == frontend.EventPull || metadata.Curr.Event == frontend.EventPush { match = match && c.Path.Match(metadata.Curr.Commit.ChangedFiles, metadata.Curr.Commit.Message) } + if metadata.Curr.Event != frontend.EventTag { + match = match && c.Branch.Match(metadata.Curr.Commit.Branch) + } return match }