tag:help.appveyor.com,2012-11-13:/discussions/problems/555-accessing-another-repository-during-a-buildAppVeyor: Discussion 2018-10-19T08:16:39Ztag:help.appveyor.com,2012-11-13:Comment/338245702014-07-18T15:28:20Z2014-07-18T15:28:20ZAccessing another repository during a build<div><p>Hi Dan,</p>
<p>That "RemoteException" is a nasty PowerShell "feature"
converting StdErr output to the exception. In this case
<code>git</code> command writes progress into StdErr. To solve this
in PS just get rid of StdErr output by appending <code>2>
$null</code>, for example:</p>
<pre>
<code>git clone ... 2> $null</code>
</pre>
<p>Regarding another repo authentication - take a look at personal
access tokens:</p>
<ul>
<li><a href=
"https://help.github.com/articles/creating-an-access-token-for-command-line-use">
https://help.github.com/articles/creating-an-access-token-for-comma...</a></li>
<li><a href=
"https://help.github.com/articles/git-automation-with-oauth-tokens">
https://help.github.com/articles/git-automation-with-oauth-tokens</a></li>
</ul></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/338245702014-07-18T15:58:05Z2014-07-18T15:58:05ZAccessing another repository during a build<div><p>That's very helpful thanks Feodor,</p>
<p>regarding the tokens - how would I use that in a build script
avoiding the prompts? The links mention caching with credential
helper which we do locally on our dev machines - but in this
environment obviously isn't an option. So once I have an access
token do I use that in place of the user name in the clone url?</p></div>Dan Jonestag:help.appveyor.com,2012-11-13:Comment/338245702014-07-18T16:05:48Z2014-07-18T16:05:48ZAccessing another repository during a build<div><p>Exactly, the token works like a username + empty password. You
can use it in the URL while cloning: <a href=
"https://github.com/blog/1270-easier-builds-and-deployments-using-git-over-https-and-oauth">
https://github.com/blog/1270-easier-builds-and-deployments-using-gi...</a></p>
<p>To avoid showing the token in the build log put it in
environment variable.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/338245702014-07-18T16:34:59Z2014-07-18T16:35:01ZAccessing another repository during a build<div><p>Hi Feodor,<br>
So I tried this:<br>
& git clone -n --depth=1 --branch=master <a href=
"https://$env:github_token:x-oauth-basic@github.com/adazzle/translations.git">
https://$env:github_token:x-oauth-basic@github.com/adazzle/translat...</a></p>
<p>github_token being an environment variable and the output is
attached.<br>
I took off the 2>$null as otherwise the build just sits there
not erroring, but also not continuing.</p>
<p>Thanks for your help so far.</p></div>Dan Jonestag:help.appveyor.com,2012-11-13:Comment/338245702014-07-18T17:36:26Z2014-07-18T17:36:26ZAccessing another repository during a build<div><p>I know it looks ugly :), but append <code>2>&1 | % {
$_.ToString() }</code> to the git command.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/338245702014-07-21T09:02:26Z2014-07-21T09:02:27ZAccessing another repository during a build<div><p>Hi Feodor,</p>
<p>Thanks again for your help so far. I appended that to the git
command and the error no longer appears. However it never get's
past that point just reading<br>
"Cloning into directory..." Last build was cancelled after 64
hours! so I'm sure it wasn't doing anything. Should I be
approaching this differently? Thanks again. Dan</p></div>Dan Jonestag:help.appveyor.com,2012-11-13:Comment/338245702014-07-21T09:05:25Z2014-07-21T09:05:25ZAccessing another repository during a build<div><p>I'm sure the problem in git clone command asking to enter
credentials. Awaiting input is the most common cause of hanging
builds. If that repository is private how do you authenticate?</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/338245702014-07-21T10:18:46Z2014-07-21T10:18:49ZAccessing another repository during a build<div><p>Yeah ok that sounds very likely. So the git command is currently
this:</p>
<p>& git clone -n --depth=1 --branch=master <a href=
"https://$env:github_token:x-oauth-basic@github.com/adazzle/translations.git">
https://$env:github_token:x-oauth-basic@github.com/adazzle/translat...</a>
C:\projects\translations 2>&1 | % { $_.ToString() }</p>
<p>$env:github_token is a variable setup using directions from a
previous post and this link <a href=
"https://github.com/blog/1270-easier-builds-and-deployments-using-git-over-https-and-oauth">
https://github.com/blog/1270-easier-builds-and-deployments-using-gi...</a></p>
<p>I'll double check over the setup to make sure I haven't missed
anything. Something isn't quite right with it though as it says in
GitHub that the token has never been used</p></div>Dan Jonestag:help.appveyor.com,2012-11-13:Comment/338245702014-07-21T10:30:25Z2014-07-21T10:30:25ZAccessing another repository during a build<div><p>Should be:</p>
<pre>
<code>& git clone -n --depth=1 --branch=master https://$($env:github_token):x-oauth-basic@github.com/adazzle/translations.git C:\projects\translations 2>&1 | % { $_.ToString() }</code>
</pre>
<p>Key change here is <code>$($env:github_token)</code></p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/338245702014-07-21T11:03:55Z2014-07-21T11:03:58ZAccessing another repository during a build<div><p>Fantastic - it is now cloning. Thank you very much for all your
help!<br>
Dan</p></div>Dan Jones