简体   繁体   中英

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

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?

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, ie package1 includes package2 in its bower.json - you'll need to include both package1 and package2 in your build project's bower.json.

Try using build access oauth token: 在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM