How to manually clone a repo in VSTS build

Problem:

One of my yeoman generator tests is failing during CI that is passing on my local dev machine.

Solution:

Clone the repo into a “generator-xxx” folder where xxx is the name of your generator instead of “s”.

Explanation:

By default, the build system clones all repos into a folder named “s”. This can cause problems when your tests are trying to load a sub generator.

clip_image001

You will get errors like the one below:

clip_image003

For the generators to be properly loaded the folder for your generator must be “generator-team” but when run on the build server it is “s”.

Luckily you are in complete control of your build using VSTS. To fix this issue I configured my build so that it would not clone my repo for me so I could do it myself and control the name.

clip_image005

Next I had to enable access to the OAuth Token on the Options tab.

clip_image007

Then I added a “Command Line” task to clone my repo. You must pass the access token using the %SYSTEM_ACCESSTOKEN% environment variable as part of your clone URL.

clip_image009

Then I simply adjusted the working directories of the remaining tasks in my build to target generator-team using $(Build.SourcesDirectory)/generator-team.

clip_image010

Add comment

Loading