【问题标题】:Install composer dependencies that reference VS Team Services git repo during build在构建期间安装引用 VS Team Services git repo 的作曲家依赖项
【发布时间】:2016-07-12 19:19:13
【问题描述】:

我有一个项目位于 Visual Studio Team Services git repo 中。其中有一个 composer 文件,它引用其他 VSTS git repos 作为依赖项。

下面是作曲家文件的示例:

{
        "name": "mybiz/app",
        "version": "1.0.0",
        "source": {
            "type": "git",
            "url": "https://mybiz.visualstudio.com/DefaultCollection/myproject/_git/mybiz-app",
            "reference": "someguid"
 }

构建定义(也在 Team Services 中)非常简单,任务是执行“composer install”。当我运行构建时,出现此错误:

Loading composer repositories with package information

Installing dependencies from lock file

Installing mybiz/app (1.0.0)
Cloning someguid
Authentication required (mybiz.visualstudio.com):
   Username:

[RuntimeException]
Aborted           

我在 Team Services 中创建了 PAT 并设置了备用凭据,但我不知道如何在构建代理上使用它们和/或它们是否是解决此问题的正确答案。

【问题讨论】:

    标签: git azure-devops azure-pipelines


    【解决方案1】:

    将 URL 更新为这种格式:

    "url": "https://alternativeusername:alternativepassword@youraccount.visualstudio.com/_git/yourproject",
    

    【讨论】:

    • 谢谢,埃迪!我明天试试看。
    • Eddie,与其把密码那样放在外面,还有更安全的方法吗?谢谢。
    • @AspiringTFSGuru 您可以在构建定义中添加一个秘密变量并将其值设置为您的密码。然后使用替换令牌任务将此值传输到“composer.json”文件中。 marketplace.visualstudio.com/items?itemName=qetza.replacetokens
    • 效果很好,埃迪。我决定使用 PAT 而不是替代凭据,所以 URL 看起来像这样:“url”:“AnyUsername:PAT@youraccount.visualstudio.com/_git/yourproject”,使用替换令牌,它看起来像这样:“AnyUsername:#{git-vsts-token} #@youraccount.visualstudio.com/_git/yourproject",
    • @Eddie Chen - MSFT 是否可以使用 ssh url?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-20
    • 2015-04-06
    • 2021-05-22
    • 2014-05-31
    • 1970-01-01
    相关资源
    最近更新 更多