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

Missing root path in GitLab webhook #2534

Closed
5 tasks done
rodarima opened this issue Oct 6, 2023 · 4 comments · Fixed by #2537
Closed
5 tasks done

Missing root path in GitLab webhook #2534

rodarima opened this issue Oct 6, 2023 · 4 comments · Fixed by #2537
Labels
bug Something isn't working forge/gitlab gitlab forge related
Milestone

Comments

@rodarima
Copy link

rodarima commented Oct 6, 2023

Component

server

Describe the bug

When enabling a new GitLab repository, the webhook is set in GitLab with the API address https://example.com/api/hook. However, the server has the WOODPECKER_ROOT_PATH=/ci, and it should be https://example.com/ci/api/hook in my case.

Changing it manually in the GitLab configuration fails because the GitLab webhook token gets erased and I don't know where to get it from, so I cannot use the webhook.

I suspect the problem is here: https://github.com/woodpecker-ci/woodpecker/blob/931af16d14e94fbf6fbb94a167251fc2d6bedded/server/forge/gitlab/gitlab.go#L450C57-L450C57

System Info

I'm using woodpecker-server 1.0.2 in NixOS:

{"source":"https://github.com/woodpecker-ci/woodpecker","version":"1.0.2"}

Additional context

No response

Validations

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Checked that the bug isn't fixed in the next version already [https://woodpecker-ci.org/faq#which-version-of-woodpecker-should-i-use]
  • Check that this is a concrete bug. For Q&A join our Discord Chat Server or the Matrix room.
@rodarima rodarima added the bug Something isn't working label Oct 6, 2023
@rodarima
Copy link
Author

rodarima commented Oct 6, 2023

Yep, this patch fixes it for me:

diff --git a/server/forge/gitlab/gitlab.go b/server/forge/gitlab/gitlab.go
index 8f2593c7..fa0fc4ea 100644
--- a/server/forge/gitlab/gitlab.go
+++ b/server/forge/gitlab/gitlab.go
@@ -447,7 +447,7 @@ func (g *GitLab) getTokenAndWebURL(link string) (token, webURL string, err error
                return "", "", err
        }
        token = uri.Query().Get("access_token")
-       webURL = fmt.Sprintf("%s://%s/api/hook", uri.Scheme, uri.Host)
+       webURL = fmt.Sprintf("%s://%s/ci/api/hook", uri.Scheme, uri.Host)
        return token, webURL, nil
 }

qwerty287 added a commit to qwerty287/woodpecker that referenced this issue Oct 7, 2023
@qwerty287 qwerty287 added the forge/gitlab gitlab forge related label Oct 7, 2023
@rodarima
Copy link
Author

rodarima commented Oct 7, 2023

Thanks for the fix @qwerty287. I also observed that in the GitLab pipelines (https://gitlab.example.com/user/repo/-/pipelines/123), the link to the Woodpecker pipeline is also missing the root path:

image

Links to

https://example.com/repos/1/pipeline/39/1

Rather than

https://example.com/ci/repos/1/pipeline/39/1

@rodarima
Copy link
Author

rodarima commented Oct 7, 2023

Seem to be coming from here:

func GetPipelineStatusLink(repo *model.Repo, pipeline *model.Pipeline, workflow *model.Workflow) string {
if workflow == nil {
return fmt.Sprintf("%s/repos/%d/pipeline/%d", server.Config.Server.Host, repo.ID, pipeline.Number)
}
return fmt.Sprintf("%s/repos/%d/pipeline/%d/%d", server.Config.Server.Host, repo.ID, pipeline.Number, workflow.PID)
}

@qwerty287
Copy link
Contributor

Yes, but your WOODPECKER_HOST env var should also contain the path (the documentation has been improved for next already)

@6543 6543 closed this as completed in #2537 Oct 7, 2023
6543 pushed a commit that referenced this issue Oct 7, 2023
- closes #2534 
- remove `IsConfigured` func from config extension.
  If `server.Config.Services.ConfigService != nil` it is always configured
@qwerty287 qwerty287 added this to the 1.0.3 milestone Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working forge/gitlab gitlab forge related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants