Skip to content

Merge request from GitLab self-hosted don't use the proper origin #9464

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

Open
maxgalli opened this issue Aug 2, 2022 · 4 comments
Open

Merge request from GitLab self-hosted don't use the proper origin #9464

maxgalli opened this issue Aug 2, 2022 · 4 comments
Labels
Improvement Minor improvement to code Needed: design decision A core team decision is required

Comments

@maxgalli
Copy link

maxgalli commented Aug 2, 2022

Details

Expected Result

Build should succeed

Actual Result

Build fails

The problem is in the command

git fetch origin --force --tags --prune --prune-tags --depth 50

which should instead be

git fetch origin --force --tags --prune --prune-tags --depth 50 merge-requests/10/head:update-docs

for this to work. These instruction should in principle be build based on what is specified on the webhook, but I can't find a way to configure it correctly.

@stsewd
Copy link
Member

stsewd commented Aug 2, 2022

Hi, this is because you are using a self-hosted version of GitLab, so RTD isn't able to format the origin properly

if self.verbose_name and self.version_type == EXTERNAL:
if self.project.git_provider_name == GITHUB_BRAND:
cmd.append(
GITHUB_PR_PULL_PATTERN.format(id=self.verbose_name)
)
if self.project.git_provider_name == GITLAB_BRAND:
cmd.append(
GITLAB_MR_PULL_PATTERN.format(id=self.verbose_name)
)

We could try to fall back to guess from the integration type if the project is from a gitlab-like server, but even with that we won't be able to report the status back, only build the MR.

@stsewd stsewd added Improvement Minor improvement to code Needed: design decision A core team decision is required labels Aug 2, 2022
@stsewd stsewd changed the title Merge request from GitLab does not seem to be triggered correctly Merge request from GitLab self-hosted don't use the proper origin Aug 2, 2022
@jcfr
Copy link

jcfr commented Jun 6, 2023

We could try to fall back to guess from the integration type

In the context of open-source project hosted at gitlab.kitware.com (e.g https://docs.vtk.org), supporting build of merge request from self-hosted GitLab would be ideal.

In the current setup, despite of being self-hosted, we were able to add a GitLab Incoming Webhook.

Considering this, attempt to guess would not be needed because by definition, the merge request event are expected to be coming from the GitLab instance associated with the configured GitLab Incoming Webhook.

To move forward, as pointed out by @stsewd , we would need to update:

if self.project.git_provider_name == GITHUB_BRAND:
cmd.append(
GITHUB_PR_PULL_PATTERN.format(id=self.verbose_name)
)
if self.project.git_provider_name == GITLAB_BRAND:
cmd.append(
GITLAB_MR_PULL_PATTERN.format(id=self.verbose_name)
)

.. to check for the type of Integration setup in the project.

Questions

  • In addition (or instead) of checking for the provider name, what about having the fetch be conditional on the Integration type ?

Example of integration / https://docs.vtk.org

image

@jcfr
Copy link

jcfr commented Jun 6, 2023

what about having the fetch be conditional on the Integration type ?

Answering my own question

Step 1

Since a given project can have multiple integration, we would need to know which integration was responsible for triggering a specific build.

This would allow to at least successfully trigger the build.

On the merge request side, it would then already be an improvement to have a (soon to be valid) preview URL available.

Step 2

In addition of knowing the integration type triggering a specific build, in the context of the GitLab integration, we could also pass down the value associated with X-Gitlab-Instance header as well as an API token that would be configured in the UI.

@Kilidsch
Copy link

Hello everyone,

Since we are affected by this as well, I wanted to ask whether there is any idea of how this issue could be resolved?

Would an option like #10397 rebased onto the current main be acceptable or is another solution desired?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Minor improvement to code Needed: design decision A core team decision is required
Projects
None yet
Development

No branches or pull requests

4 participants