Git Product home page Git Product logo

Comments (7)

SebastianBalle avatar SebastianBalle commented on June 16, 2024 1

@jacebrowning I think this would be valuable to add if you are considering having some documentation on CI implementations. The documentation only describes the local development which, I would say, is only half of the work.

You could of course simply redirect the user to the official documentation page from the different CI providers but it would be cool if you could have a small compact guide for how to implement the tool in the different systems.

I can help draft such a documentation for Azure DevOps at least.

from gitman.

jacebrowning avatar jacebrowning commented on June 16, 2024

Gitman calls git as a subprocess. You emulate this in a Python shell:

python
>>> import subprocess
>>> subprocess.run(["git", "clone", "https://dev.azure.com/***/***/***/"])

Does that work?

Here are the setup docs in case you missed them: https://gitman.readthedocs.io/en/latest/setup/git/

from gitman.

daniel-brosche avatar daniel-brosche commented on June 16, 2024

As mentioned try at first to clone the repository via calling git as subprocess to investigate the problem without gitman.
Have found some tipps that are dealing with this issue, may this help: https://stackoverflow.com/questions/35834117/authentication-failed-for-https-xxx-visualstudio-com-defaultcollection-git-pr

from gitman.

SebastianBalle avatar SebastianBalle commented on June 16, 2024

I am currently investigating this as I would like to find a solution that works both for local development and CI. I would prefer to configure git using command line for automatic build to be authenticated as well. FYI I am working with Azure Pipelines.

It seems like if you would like to use the System.AccessToken for authenticating using the identity of the pipeline. This will be done using the folllowing git command git clone -c http.extraheader="AUTHORIZATION: bearer <System_AccessToken>" [some-repo-url]. Is it possible to somehow inject this header into the git command invoked by the Python subprocess implemented in Gitman?

from gitman.

jacebrowning avatar jacebrowning commented on June 16, 2024

You could try passing the extra parameter using the params setting in the Gitman configuration file: https://gitman.readthedocs.io/en/latest/setup/configuration/#gitman.models.source.Source--params

Unfortunately that will mean keeping your secret in Git, but let's see if it clones first, then work on alternative approaches.

from gitman.

SebastianBalle avatar SebastianBalle commented on June 16, 2024

I manage to authenticate to the repository using the system token in Azure DevOps like so.
git config --global http.extraheader "AUTHORIZATION: bearer $(System.AccessToken)". This command was executed before any Gitman commands. Alternatively I could've executed the Gitman command using the params configuration but this would imply that I use a system token for authenticating locally.

In addition I had to disable Protect access to repositories in YAML pipelines in Azure DevOps. After this I could clone the repositories in Azure Pipelines using HTTPS. In Azure DevOps it is not possible to clone other repositories using command line git if this setting is enabled. More information can found here.

Locally I simply used the Git credential manager.

This setup allows me to have the same Gitman configuration file for both local development and automated builds in Azure DevOps using HTTPS.

from gitman.

jacebrowning avatar jacebrowning commented on June 16, 2024

@SebastianBalle thanks for sharing!

Would that be worth adding to the setup docs or do you think it's mostly specific to your situation?

from gitman.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.