Bower install build step on Visual Studio Team Services with dependency of another team project

情到浓时终转凉″ 提交于 2020-01-07 01:53:10

问题


In our bower.json we have this dependency:

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

I'm using alternate credentials and this works fine on my machine.

When I run this on Visual Studio Team Services it fails as it doesn't have my credentials. I don't want to add my personal alternate credentials to the bower.json file. Another solution would be to just add the files to our project without using bower.

Is there another solution to this?


回答1:


I ran across this same issue and fixed it like this:

  1. Make sure to select Options > Allow Scripts to Access OAuth Token in the build definition.
  2. Add a powershell script task to your build definition task, before your bower install command task

    $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
    

The one caveat I found is that if you have a dependency tree of bower packages hosted on VSTS, you'll have to add all of the dependencies in the tree to your root bower.json file, i.e. package1 includes package2 in its bower.json - you'll need to include both package1 and package2 in your build project's bower.json.




回答2:


Try using build access oauth token:

Check this link for reference: Use the OAuth token to access the REST API



来源:https://stackoverflow.com/questions/36445962/bower-install-build-step-on-visual-studio-team-services-with-dependency-of-anoth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!