Nant task: vaultcheckin - Not checking in the correct file
Moderator: SourceGear
Nant task: vaultcheckin - Not checking in the correct file
Hi, I am trying to do this, using NAnt (and draco.net):
Checkout AssemblyInfo.cs
Update the version in AssemblyInfo.cs
Checkin the updated AssemblyInfo.cs
I'm using a recent nightly build of NAnt and the latest vault nant tasks.
It doesn't seem as though the correct file is being checked back into Vault.
Any help would be appreciated.
Thanks
Jim
This is the output that I get:
Exception updating hidden and working file: Object reference not set to an instance of an object.
[vaultcheckout] Exception of type VaultClientOperationsLib.GetLatestVersionFailedException was thrown.
IncrementAssemblyVersion:
[script] Scanning assembly "mh3ynlfd" for extensions.
Previous version: 1.0.1
New version: 1.0.2
[vaultcheckin] Set working folder for $/MyProject to C:\WINDOWS\TEMP\nant_checkinfor_AssemblyInfo.cs from
[vaultcheckin] AssemblyInfo.cs successfully checked in.
[vaultcheckin] Restoring working folder for $/MyProject to
------------------------
This is what my nant script looks like:
<vaultcheckout url="http://myvaulturl" username="admin" password="admin" repository="Default Repository" path="$/MyProject/AssemblyInfo.cs" failonerror="false" />
<call target="IncrementAssemblyVersion" failonerror="false" />
<vaultcheckin url="http://myvaulturl" username="admin" password="admin" repository="Default Repository" path="$/MyProject/AssemblyInfo.cs" diskfile="${nant.project.basedir}/AssemblyInfo.cs" comment="Automated check-in: Increment assembly version" />
Checkout AssemblyInfo.cs
Update the version in AssemblyInfo.cs
Checkin the updated AssemblyInfo.cs
I'm using a recent nightly build of NAnt and the latest vault nant tasks.
It doesn't seem as though the correct file is being checked back into Vault.
Any help would be appreciated.
Thanks
Jim
This is the output that I get:
Exception updating hidden and working file: Object reference not set to an instance of an object.
[vaultcheckout] Exception of type VaultClientOperationsLib.GetLatestVersionFailedException was thrown.
IncrementAssemblyVersion:
[script] Scanning assembly "mh3ynlfd" for extensions.
Previous version: 1.0.1
New version: 1.0.2
[vaultcheckin] Set working folder for $/MyProject to C:\WINDOWS\TEMP\nant_checkinfor_AssemblyInfo.cs from
[vaultcheckin] AssemblyInfo.cs successfully checked in.
[vaultcheckin] Restoring working folder for $/MyProject to
------------------------
This is what my nant script looks like:
<vaultcheckout url="http://myvaulturl" username="admin" password="admin" repository="Default Repository" path="$/MyProject/AssemblyInfo.cs" failonerror="false" />
<call target="IncrementAssemblyVersion" failonerror="false" />
<vaultcheckin url="http://myvaulturl" username="admin" password="admin" repository="Default Repository" path="$/MyProject/AssemblyInfo.cs" diskfile="${nant.project.basedir}/AssemblyInfo.cs" comment="Automated check-in: Increment assembly version" />
I am the author...
Sorry, i just wanted to reply to this so that I get emails when someone replies to the thread... I am the author of this post and didn't realize I wasn't logged in
NAnt version: nant-0.85-nightly-2005-10-26
Vault version (server & client): 3.1.3
I have the latest NAnt tasks (downloaded a few days ago)
I'm pretty sure that the repository path does not have a working folder. This is because I'm calling vault from a server with Draco.Net running and I don't really use vault on that machine other than to do nightly builds. Also, the working folder would be different because each build is built to a specific folder.
Can I not check in a file to a repository path that doesn't have a working folder set? That's why I thought I was setting the diskfile property.
Thanks for the help with this!
Vault version (server & client): 3.1.3
I have the latest NAnt tasks (downloaded a few days ago)
I'm pretty sure that the repository path does not have a working folder. This is because I'm calling vault from a server with Draco.Net running and I don't really use vault on that machine other than to do nightly builds. Also, the working folder would be different because each build is built to a specific folder.
Can I not check in a file to a repository path that doesn't have a working folder set? That's why I thought I was setting the diskfile property.
Thanks for the help with this!
ian_sg wrote:Also, can you verify that the repository path in question ($/MyProject in your example) has a working folder set before the checkout? If this is the problem, we should surely be giving a better error message, but this is possibly the culprit.
Okay that's almost certainly the problem. Vaultcheckout doesn't know where to put the file.
If your repository is not set to require exclusive locks (which is the default) you can retrieve the file using vaultgetfile instead, which will let you set a path for the retrieved file:
You may also need to turn off the read-only attribute on the retrieved file, which I believe can be done with a NAnt core task.
If you're requiring exclusive locks, you'll have to set a working folder before the vaultcheckout, which can't be done from NAnt. So hopefully you're not requiring exclusive locks.
If your repository is not set to require exclusive locks (which is the default) you can retrieve the file using vaultgetfile instead, which will let you set a path for the retrieved file:
Code: Select all
<vaultgetfile
url="http://myvaulturl"
username="admin"
password="admin"
repository="Default Repository"
path="$/MyProject/AssemblyInfo.cs"
destination="${nant.project.basedir}" />
If you're requiring exclusive locks, you'll have to set a working folder before the vaultcheckout, which can't be done from NAnt. So hopefully you're not requiring exclusive locks.
Ian Olsen
SourceGear
SourceGear
Hi Ian,
I tried putting <vaultgetFile> before and then after the <vaultcheckout>. I also tried removing the <vaultcheckout> call. But in each case, I still got the same result that the correct file is not getting checked into Vault.
Maybe I'm mistaken, but this is the logic that went through my head:
I can checkout the file (w/o a working dir).
I can make sure that the file I want to check in exists.
The checkin command will check in the file that I specify, regardless of the working folder.
I guess if it comes down to it, I can set a working folder to some temp dir and move the file that I want to check in to that folder... it just seems like sort of a hack to me.
Thanks again for your help
Jim
I tried putting <vaultgetFile> before and then after the <vaultcheckout>. I also tried removing the <vaultcheckout> call. But in each case, I still got the same result that the correct file is not getting checked into Vault.
Maybe I'm mistaken, but this is the logic that went through my head:
I can checkout the file (w/o a working dir).
I can make sure that the file I want to check in exists.
The checkin command will check in the file that I specify, regardless of the working folder.
I guess if it comes down to it, I can set a working folder to some temp dir and move the file that I want to check in to that folder... it just seems like sort of a hack to me.
Thanks again for your help
Jim
ian_sg wrote:Okay that's almost certainly the problem. Vaultcheckout doesn't know where to put the file.
If your repository is not set to require exclusive locks (which is the default) you can retrieve the file using vaultgetfile instead, which will let you set a path for the retrieved file:
You may also need to turn off the read-only attribute on the retrieved file, which I believe can be done with a NAnt core task.Code: Select all
<vaultgetfile url="http://myvaulturl" username="admin" password="admin" repository="Default Repository" path="$/MyProject/AssemblyInfo.cs" destination="${nant.project.basedir}" />
If you're requiring exclusive locks, you'll have to set a working folder before the vaultcheckout, which can't be done from NAnt. So hopefully you're not requiring exclusive locks.
Having the same issue
I am having the exact same issue when trying to check a file in from NAnt. I am using Vault 3.1.5 and NAnt 0.85 RC3. Tried getting file first, checking out first and setting the working diretory through the vault client. Everytime the checkin runs it acts though it is undoing the checkout and incrementing the version.
Foud a work around
I was using the same flow that you recommend except I was using the get file command since there is no NAnt task to set a working folder. I am using http://vaultpub.sourcegear.com/build/latest/doc/ as my reference for vault NAnt tasks. It would actually perform a checkin (increment the version number and say who checked in the file and date/time and all that good stuff) but wouldn't actually upload the file. Also, it showed success inside the NAnt log.
Decided just to call the command line from NAnt instead and got everything to work pretty well. If anyone is interested in seeing the NAnt commands let me know and I can upload them. My basic setup is CruiseControl.Net, NAnt, NUnit2, FxCop, Simian, with the Vault as the source control provider. Have been able to get all of it to work and its pretty neat.
Decided just to call the command line from NAnt instead and got everything to work pretty well. If anyone is interested in seeing the NAnt commands let me know and I can upload them. My basic setup is CruiseControl.Net, NAnt, NUnit2, FxCop, Simian, with the Vault as the source control provider. Have been able to get all of it to work and its pretty neat.
Re: Foud a work around
Yeah man, I'm interested in seeing how you got it working... I sort of gave up on this since it was a relatively low priority for me.
bozer wrote:I was using the same flow that you recommend except I was using the get file command since there is no NAnt task to set a working folder. I am using http://vaultpub.sourcegear.com/build/latest/doc/ as my reference for vault NAnt tasks. It would actually perform a checkin (increment the version number and say who checked in the file and date/time and all that good stuff) but wouldn't actually upload the file. Also, it showed success inside the NAnt log.
Decided just to call the command line from NAnt instead and got everything to work pretty well. If anyone is interested in seeing the NAnt commands let me know and I can upload them. My basic setup is CruiseControl.Net, NAnt, NUnit2, FxCop, Simian, with the Vault as the source control provider. Have been able to get all of it to work and its pretty neat.
Command line calls from NAnt to make this work
Sorry, I meant to post this a few days ago.
<!-- Sets the working folder -->
<exec program="C:\vaultapi\vault.exe" commandline="setworkingfolder ${vault.lib.internal}/ ${path.build} -user ${vault.username} -password ${vault.password} -host ${vault.url} -repository ${vault.repository}" failonerror="false" />
<!-- Checks out the files -->
<exec program="C:\vaultapi\vault.exe" commandline="checkout ${vault.lib.internal}/file.dll -user ${vault.username} -password ${vault.password} -host ${vault.url} -repository ${vault.repository}" failonerror="false" />
Next I use the NAnt Vault Task to get other files needed for compilation, that one seems to work good as long as you don't need to modify and check any of those in.
<!-- Check in file -->
<exec program="C:\vaultapi\vault.exe" commandline="checkin ${vault.lib.internal}/file.dll -user ${vault.username} -password ${vault.password} -host ${vault.url} -repository ${vault.repository}" failonerror="false" />
<!-- Remove working folder association -->
<exec program="C:\vaultapi\vault.exe" commandline="unsetworkingfolder ${vault.lib.internal}/ -user ${vault.username} -password ${vault.password} -host ${vault.url} -repository ${vault.repository}" failonerror="false" />
<!-- Sets the working folder -->
<exec program="C:\vaultapi\vault.exe" commandline="setworkingfolder ${vault.lib.internal}/ ${path.build} -user ${vault.username} -password ${vault.password} -host ${vault.url} -repository ${vault.repository}" failonerror="false" />
<!-- Checks out the files -->
<exec program="C:\vaultapi\vault.exe" commandline="checkout ${vault.lib.internal}/file.dll -user ${vault.username} -password ${vault.password} -host ${vault.url} -repository ${vault.repository}" failonerror="false" />
Next I use the NAnt Vault Task to get other files needed for compilation, that one seems to work good as long as you don't need to modify and check any of those in.
<!-- Check in file -->
<exec program="C:\vaultapi\vault.exe" commandline="checkin ${vault.lib.internal}/file.dll -user ${vault.username} -password ${vault.password} -host ${vault.url} -repository ${vault.repository}" failonerror="false" />
<!-- Remove working folder association -->
<exec program="C:\vaultapi\vault.exe" commandline="unsetworkingfolder ${vault.lib.internal}/ -user ${vault.username} -password ${vault.password} -host ${vault.url} -repository ${vault.repository}" failonerror="false" />
Re: Command line calls from NAnt to make this work
Thanks man!
bozer wrote:Sorry, I meant to post this a few days ago.
<!-- Sets the working folder -->
<exec program="C:\vaultapi\vault.exe" commandline="setworkingfolder ${vault.lib.internal}/ ${path.build} -user ${vault.username} -password ${vault.password} -host ${vault.url} -repository ${vault.repository}" failonerror="false" />
<!-- Checks out the files -->
<exec program="C:\vaultapi\vault.exe" commandline="checkout ${vault.lib.internal}/file.dll -user ${vault.username} -password ${vault.password} -host ${vault.url} -repository ${vault.repository}" failonerror="false" />
Next I use the NAnt Vault Task to get other files needed for compilation, that one seems to work good as long as you don't need to modify and check any of those in.
<!-- Check in file -->
<exec program="C:\vaultapi\vault.exe" commandline="checkin ${vault.lib.internal}/file.dll -user ${vault.username} -password ${vault.password} -host ${vault.url} -repository ${vault.repository}" failonerror="false" />
<!-- Remove working folder association -->
<exec program="C:\vaultapi\vault.exe" commandline="unsetworkingfolder ${vault.lib.internal}/ -user ${vault.username} -password ${vault.password} -host ${vault.url} -repository ${vault.repository}" failonerror="false" />