【问题标题】:Bower install build step on Visual Studio Team Services with dependency of another team projectBower 在依赖另一个团队项目的 Visual Studio Team Services 上安装构建步骤
【发布时间】:2016-04-06 08:46:45
【问题描述】:

在我们的 bower.json 中,我们有这个依赖:

"ourpackage": "git+https://xxx.visualstudio.com/DefaultCollection/_git/ourpackage#1.2.3"

我正在使用备用凭据,这在我的机器上运行良好。

当我在 Visual Studio Team Services 上运行它时,它会失败,因为它没有我的凭据。我不想将我的个人备用凭据添加到 bower.json 文件中。另一种解决方案是直接将文件添加到我们的项目中,而不使用 bower。

还有其他解决方案吗?

【问题讨论】:

    标签: bower build-process credentials azure-devops


    【解决方案1】:

    我遇到了同样的问题并像这样修复它:

    1. 确保在构建定义中选择选项 > 允许脚本访问 OAuth 令牌。
    2. 在您的 bower install 命令任务之前,将 powershell 脚本任务添加到您的构建定义任务中

      $file = "path\to\bower.json"
      
      (Get-Content $file| ForEach-Object { $_ -replace "https://your.visualstudio.com", "https://un:$env:SYSTEM_ACCESSTOKEN@your.visualstudio.com" }) | Set-Content $file
      

    我发现的一个警告是,如果您有一个托管在 VSTS 上的 bower 包的依赖关系树,则必须将树中的所有依赖项添加到根 bower.json 文件中,即 package1 在其bower.json - 您需要在构建项目的 bower.json 中包含 package1 和 package2。

    【讨论】:

      【解决方案2】:

      尝试使用构建访问 oauth 令牌:

      查看此链接以供参考:Use the OAuth token to access the REST API

      【讨论】:

      • 如何使用它来更改 bower/git 凭据?
      • @PeterHedberg 添加一个 powershell 步骤以获取当前访问令牌并在构建之前将其写入 bower.josn 文件。
      • 啊,好的。我试试看!
      • 我发现我需要在“获取源”步骤中“清理”。即使文件已成功更新,Git 似乎也会维护一些没有“un:”前缀的遥控器。你会随机收到一些包的错误:ECMDERR Failed to execute "git ls-remote --tags --heads xxxx.visualstudio.com/DefaultCollection/DevOps/_git/xxxxxx", exit code of #128 fatal: could not read Username for 'xxxx.visualstudio.com':终端提示已禁用'。清除构建目录似乎可以防止这种行为。
      猜你喜欢
      • 1970-01-01
      • 2013-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-15
      • 1970-01-01
      相关资源
      最近更新 更多