Skip to content

Commit ad8631d

Browse files
authored
fix(api): inject git_branch_exists variable for retention only if vcs info exists (#6394)
1 parent 942c7c8 commit ad8631d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

engine/api/purge/purge_run.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ func ApplyRetentionPolicyOnWorkflow(ctx context.Context, store cache.Store, db *
151151
if err != nil {
152152
log.Error(ctx, "error on run %v:%d err:%v", wf.Name, run.Number, err)
153153
continue
154-
155154
}
156155
}
157156

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

300299
vars[RunStatus] = run.Status
301300

0 commit comments

Comments
 (0)