Skip to content

Commit ef3531e

Browse files
author
chhsia0
committed
Set secret token in CreateHook only if non-empty.
1 parent fdc0060 commit ef3531e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

scm/driver/gitlab/repo.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@ func (s *repositoryService) ListStatus(ctx context.Context, repo, ref string, op
114114
func (s *repositoryService) CreateHook(ctx context.Context, repo string, input *scm.HookInput) (*scm.Hook, *scm.Response, error) {
115115
params := url.Values{}
116116
params.Set("url", input.Target)
117-
params.Set("token", input.Secret)
117+
// Earlier versions of gitlab returns an error if the token was an empty string, so we only set the
118+
// token value if non-empty.
119+
if input.Secret != "" {
120+
params.Set("token", input.Secret)
121+
}
118122
params.Set("enable_ssl_verification", strconv.FormatBool(!input.SkipVerify))
119123
for k, v := range convertFromHookEvents(input.Events) {
120124
params.Set(k, strconv.FormatBool(v))

0 commit comments

Comments
 (0)