Skip to content

Commit

Permalink
fix(api): inject git_branch_exists variable for retention only if vcs…
Browse files Browse the repository at this point in the history
… info exists (#6394)
  • Loading branch information
richardlt authored Dec 27, 2022
1 parent 942c7c8 commit ad8631d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions engine/api/purge/purge_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ func ApplyRetentionPolicyOnWorkflow(ctx context.Context, store cache.Store, db *
if err != nil {
log.Error(ctx, "error on run %v:%d err:%v", wf.Name, run.Number, err)
continue

}
}

Expand Down Expand Up @@ -291,11 +290,11 @@ func purgeComputeVariables(ctx context.Context, luaCheck *luascript.Check, run s
if has {
_, exist = branchesMap[b]
}
if has && vcsClient == nil {
return sdk.NewErrorFrom(sdk.ErrUnknownError, "vcsClient nil but git branch exists")
if vcsClient != nil {
// Only inject the "git_branch_exist" variable if a vcs client exists to make sure that its value is accurate
vars[RunGitBranchExist] = strconv.FormatBool(exist)
}
vars[RunHasGitBranch] = strconv.FormatBool(has)
vars[RunGitBranchExist] = strconv.FormatBool(exist)

vars[RunStatus] = run.Status

Expand Down

0 comments on commit ad8631d

Please sign in to comment.