I'm trying to automate pulling the latest version of our code from bitbucket using git.exe via psake in Powershell but I'm struggling with a number of issues.
I've got the following code in a Task:
Exec {
&('c:\Program Files\Git\bin\git.exe') pull --progress --no-rebase -v origin
}
but I get the following error:
Error: 25/04/2016 22:51:02:
At C:\work\mycompany\buildapp\psakefile.ps1:117 char:5 +
&('c:\Program Files\Git\bin\git.exe') pull --progress --no-rebase -v origin
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[<<==>>] Exception: From bitbucket.org:mybitbucketusername/work
I assume that's because I'm not calling git.exe from my clone folder but how do I do this? Is there a way to a) call git from my current location and apply it to a specific clone folder? or b) if a) can't be done, how do I change folder in psake?
Assuming i can fix the first problem, how can I find out the exact error returned from git. Just getting Exception: From bitbucket.org is too vague.
Is there a better way to pull my code from bitbucket? Should I call git bash (for windows) using psake from Powershell? Is that better? If so, how do I call it with the specific command line.
If you want me to provide more information, please let me know.
Update 1:
This is what I get when I call git pull
Error: 26/04/2016 15:46:30:
At C:\work\mycompany\buildapp\psakefile.ps1:120 char:5 +
&('c:\Program Files\Git\bin\git.exe') pull +
[<<==>>] Exception: There is no tracking information for the current branch.
This is to be expected as c:\work\mycompany\buildapp is not the cloned folder. It is a subfolder of the cloned folder.
I need to be able to call git while in c:\work\mycompany\buildapp
(as this is where my script is running from) but I need git to pull data from c:\work\mycompany\
.
I hope the above clarifies my question.
Thanks.
UPDATE 2:
The following git command lines work perfectly running a command line being called from any folder:
git clone git@bitbucket.org:myusername/work.git "c:/Work/"
git --git-dir=c:\work\.git --work-tree=c:\work pull origin master
The following works with PSake:
Exec {
&('c:\Program Files\Git\bin\git.exe') clone
git@bitbucket.org:myusername/work.git 'C:/Work/'
}
But pull still doesn't work when called this way:
exec {
&('c:\program files\git\bin\git.exe') --git-dir=c:\work\.git
--work-tree=c:\work pull origin master
}
I still get an error:
Error: 29/04/2016 10:06:36:
At C:\temp\buildapp\psakefile.ps1:124 char:8 +
&('c:\program files\git\bin\git.exe') --git-dir=c:\work\.git - ... +
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[<<==>>] Exception: From bitbucket.org:myusername/work
Unfortunately the exception doesn't tell us much.
I've tried various combinations with quotes/double quote with the arguments but to no avail.
Any ideas?