Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): inject git_branch_exists var in retention only if vcs info exists #6394

Merged
merged 1 commit into from
Dec 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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