portainer / portainer

Making Docker and Kubernetes management easy.
https://www.portainer.io
zlib License
31.08k stars 2.48k forks source link

creating stack from a self hosted Azure DevOps git repository #10866

Open ssn-github opened 11 months ago

ssn-github commented 11 months ago

Before you start please confirm the following.

Problem Description

creating a stack from a self hosted Azure DevOps git repository fails with error: git repository: failed to clone git repository: unexpected client error: unexpected requesting "URL/_git/REPO/git-upload-pack" status code: 400

Expected Behavior

stack should be created

Actual Behavior

fails to create stack with error: git repository: failed to clone git repository: unexpected client error: unexpected requesting "URL/_git/REPO/git-upload-pack" status code: 400

Steps to Reproduce

  1. go to stacks
  2. click on Add Stack
  3. select Repository as Build method
  4. fill out all required information and use the url of the self hosted Azure DevOps repository e.g. https://devops.company.com/DefaultCollection/PROJECT/_git/REPO
  5. Deploy Stack

Portainer logs or screenshots

No response

Portainer version

2.19.4

Portainer Edition

Community Edition (CE)

Platform and Version

Docker 24.0.7

OS and Architecture

AlmaLinux 9.2

Browser

No response

What command did you use to deploy Portainer?

No response

Additional Information

The same issue has already been submitted here: https://github.com/portainer/portainer/issues/8732 but couldn't be reproduced because not a self hosted Azure DevOps was used for testing.

The underlying issue seems to be that go-git didn't support multi_ack and has been discussed here: https://github.com/portainer/portainer/issues/1926 which resulted in a workaround that downloads the repository as a zip-file instead of using git clone. If I understand the code correctly it just checks the domain part of the URL to detect if it is an Azure DevOps repository or not:

https://github.com/portainer/portainer/blob/develop/api/git/azure.go

const (
    azureDevOpsHost        = "dev.azure.com"
    visualStudioHostSuffix = ".visualstudio.com"
)

func isAzureUrl(s string) bool {
    return strings.Contains(s, azureDevOpsHost) ||
        strings.Contains(s, visualStudioHostSuffix)
}

While this works fine for the cloud version it fails to detect self hosted Azure DevOps repositories and tries to use git clone instead.

Now an easy fix would probably be something like a "Is Azure DevOps repository" checkbox in the Add Stack GUI to force the zip download instead of git clone or an additional setting to add custom Azure DevOps domains. It also seems that the underlying issue in go-git has been partially fixed by now: https://github.com/go-git/go-git/issues/64 so maybe that would also be an option.

jonasbirkelof commented 7 months ago

Is there any fix for this? I can not use our internal devops environment with portainer.

softandbyte commented 6 months ago

Any update regarding this ? We are facing the same problem.

sohilww commented 2 months ago

Any update regarding this ? We are facing the same problem.