4.0.2 New Nant Tasks Missing Examples

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

AdamL3024
Posts: 6
Joined: Wed Apr 18, 2007 9:21 am

4.0.2 New Nant Tasks Missing Examples

Post by AdamL3024 » Tue Jul 17, 2007 9:45 am

Hello All,

It would appear that the new Nant Contrib files for Valut 4.0.2 have changed :twisted: . So after updating to the new version on Vault and to the new contrib files all my checkin, checkout, getlatest scripts are now failing as it is expecting parameters I do not pass. Can anyone tell me the general parameters need to be passed to a task in the NEW contrib files as the new documentation does not provide any examples.

Example of the old get file: What should be passed for the new files 4.0.2 (Poor documentation on SourceGears Part)

<vaultgetfile url="http://localhost"
username="username"
password="password"
repository="repository"
path="$/Project/Directory/File.cs"
destination="C:\Directory\File.cs"/>

Thanks Again,

Adam

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Tue Jul 17, 2007 10:22 am

There is a chm file that is included in the NAnt tasks distribution. That has all of the documentation for the new tasks. For examples using the new NAnt tasks, look at: http://support.sourcegear.com/viewtopic.php?t=8019

AdamL3024
Posts: 6
Joined: Wed Apr 18, 2007 9:21 am

Post by AdamL3024 » Tue Jul 17, 2007 11:24 am

I have looked at that example page and the documentation. The documentation is not usable as it does not say what needs to be passed. The example link above appears to have only 1 example from 4.0.2 but does not seem to resemble NANT Script?

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Tue Jul 17, 2007 12:09 pm

All of the 4.0.1 examples work for 4.0.2 as well, and will continue to work for all 4.0.x releases.

Here's the example of how to do the get that you posted in your first post

Code: Select all

<vaultgettolocationoutsideworkingfolder destPath="C:\Directory">
      <vaultfileset>
        <include name="$/Project/Directory/File.cs" />
      </vaultfileset> 
</vaultgettolocationoutsideworkingfolder>
You can optionally provide a getoptions structure to control how the get behaves with regard to writable flags and file time.

You're right that our chm file is not as explicit as it should be in the description of which attributes are required and which are not. I'll log a bug against our documentation and make sure that it's fixed soon.

AdamL3024
Posts: 6
Joined: Wed Apr 18, 2007 9:21 am

Post by AdamL3024 » Wed Jul 18, 2007 1:52 pm

Thanks for the reply but it would appear that your above post is incomplete as it does not list any information such as the URL,UserName, and Password. How does it get this info there is no way to easily discover this in your documentation either??

:?:

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Wed Jul 18, 2007 2:44 pm

As is shown in the NAnt examples post above, here's the steps to set your connection:

Code: Select all

<!--Load the Fortress or Vault Nant tasks-->
    <loadtasks path="c:/path/to/nant/tasks/dll" verbose="true" />
    <!--Set the login options:  username, password, and server url-->
    <vaultsetloginoptions user="username" password="password" URL="http://VaultServer/VaultService" />
    <!--Connect to NantTestRep-->
    <vaultsetrepository repositoryName="NantTestRep" /> 
Any subsequent Vault NAnt task calls will use that connection.

AdamL3024
Posts: 6
Joined: Wed Apr 18, 2007 9:21 am

Solution

Post by AdamL3024 » Thu Jul 19, 2007 7:52 am

Thank You Very Much! :D

Ok below I have posted the complete solution for how to create a task called get latest using 4.0.2 Nant Task (although from the documentation it might have been hard to determine that the old getLatest task name has been changed to vaultgettolocationoutsideworkingfolder )

<target name="getLatest">

<!--Load the Vault Nant tasks-->
<!-- The folder you point to CAN ONLY CONTAIN THE NANT .DLL's for the new Contrib Files so NO other contrib files -->
<loadtasks path="C:\BuildTools\nant\bin\dll" verbose="true" />

<!--Set the login options: username, password, and server url URL="http://vaultserver/VaultService-->
<vaultsetloginoptions user="${UserName}" password="${Password}" URL="${VaultServer}" />

<!-- Set the Nant Repository you can get this when you log into vault or via options -->
<vaultsetrepository repositoryName="${Repository}" />

<vaultgettolocationoutsideworkingfolder destPath="C:\SolutionFolderLocal">
<vaultfileset>
<include name="$/SolutionFolderVault" />
</vaultfileset>
</vaultgettolocationoutsideworkingfolder>

</target>

- I am also assuming this gets latest on everything. So this should overwrite all files in the solution regardless if they are checked out, not ther etc.

AdamL3024
Posts: 6
Joined: Wed Apr 18, 2007 9:21 am

Post by AdamL3024 » Thu Jul 19, 2007 11:41 am

Jeremy,

Is there a way to use the above command but specify the dest folder as a working folder. I tried removing it but it says its required. But when I have it set to the actual working folder it tells me to remove it this should be a bug of sorts. Or you should enable the destFolder to be specified in the standard valutget class not sure why it was removed or create an override for that constructor etc.

Let me know thanks,

Adam

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Thu Jul 19, 2007 11:50 am

If you want to do a get to a working folder, then use the <vaultget> task. It doesn't take a destPath, so you will need to verify that you've already set the working folder before calling the vaultget task. All of this is covered in the second example on this page: http://support.sourcegear.com/viewtopic.php?t=8019

JoeD
Posts: 4
Joined: Mon Jul 23, 2007 10:09 am

Post by JoeD » Mon Jul 23, 2007 10:34 am

Hello, my name is Joe and I work with AdamL3024. The information you have given us so far has worked perfectly and we are now able to get latest and Build. The only problem we are still having is that CheckInVersion fails every other time we run the script. It seems to always be failing the first time we run the script and check out the code. When we rerun the script and the file is already checked out from the precious run it Checks in fine, it's only occurring as I said when we first Check Out the File. If you have any ideas on how we can fix this I would really appreciate it and if you need any other information about the error or something please let me know as soon as possible. Thanks.

shannon

Post by shannon » Mon Jul 23, 2007 12:31 pm

Hi Joe,

Glad to hear you've got your build back up and running again. Can you give me any more information about this error? The output/error messages and the section of the script that seems to be failing would probably be helpful.

Also, is it only one particular file the operations are failing on or several?

JoeD
Posts: 4
Joined: Mon Jul 23, 2007 10:09 am

Post by JoeD » Tue Jul 24, 2007 2:11 pm

Hello Shannon,

Sorry it took so long to respond. We are running into a few different issues with the file still. The first issue that has been occurring is the issue I stated in the previous Post. Going in order on the file, first we Log into Vault. Next we check out the version file, then call an executable to change the version file, and then we check the file back into Vault. As I stated before the issue occurs when a Target is called. All this target does is use the task vaultcheckin and the vaultfileset task to check the file back in. Here is an example of the tasks below.

<vaultcheckin unchanged="checkin">
<vaultfileset>
<include name="C:\project\directory\file.cs>
</vaultfileset>
</vaultcheckin>

Originally I had it setup without the unchanged parameter, but added it later when the checkin kept failing.

Here is the exact Error Message that I receive when the CheckIn fails:

"INTERNAL ERROR
System.exception: The current change set does not have any items for C:\project\directory\file.cs
at VaultClientIntegrationLib.ServerOperations.ProcessCommandCommit(String[] objectPaths, UnchangedHandler unchanged, Boolean keepChe
ckedOut, LocalCopyType localCopy)
at VaultClientIntegrationLib.ServerOperations.ProcessCommandCheckIn(String[] objectPaths, UnchangedHandler unchanged, Boolean keepCh
eckedOut, LocalCopyType localCopy)
at NAnt.Contrib.Tasks.SourceGearVault.vaultcheckin.ExecuteTask()
at NAnt.Core.Task.Execute()
at NAnt.Core.Target.Execute()
at NAnt.Core.Project.Execute(String targetName, Boolean forceDependencies)
at NAnt.Core.Tasks.CallTask.ExecuteTask()
at NAnt.Core.Task.Execute()
at NAnt.Core.Target.Execute()
at NAnt.Core.Project.Execute(String targetName, Boolean forceDependencies)
at NAnt.Core.Project.Execute()
at NAnt.Core.Project.Run()

Please send bug report to nant-developers@lists.sourceforge.net."

-- END OF ERROR MESSAGE --

Any Suggestions, the SOONER the better, we need this to be working ASAP!!. Thank you. Joe

shannon

Post by shannon » Tue Jul 24, 2007 2:32 pm

Joe,

Would it be possible for you to send me your build script using the email button below this post? It would be much easier for me to track this down if I could run some tests with your script.

JoeD
Posts: 4
Joined: Mon Jul 23, 2007 10:09 am

Post by JoeD » Wed Jul 25, 2007 8:50 am

I have copied the portion of the script that is used to CheckOut, Change, and then CheckIn the Version.cs file.


<?xml version="1.0" encoding="utf-8" ?>
<project name="DefaultBuild" default="complete" basedir="." >
<description>This file Gets Latest on All Solutions Rebuilds and Publishes the Website </description>


<property name="ProjectName" value="C:\Folder\Folder\Project" />



<call target="CheckOutVersion"/>

<call target="ChangeVersion"/>

<call target="CheckInVersion"/>




<!-- Check Out VersionInfo.cs -->
<target name="CheckOutVersion">
<vaultcheckout>
<vaultfileset>
<include name="${ProjectName}\directory\VersionFile.cs" />
</vaultfileset>
</vaultcheckout>
</target>


<target name="ChangeVersion">
<exec program="C:\ExecutablePath\ChangeXMLVersion.exe"/>
</target>


<target name="CheckInVersion">
<vaultcheckin unchanged="CheckIn">
<vaultfileset>

<include name="${ProjectName}\directory\VersionFile.cs" />

</vaultfileset>
</vaultcheckin>
</target>


</project>

This is exactly what occurs during the change version tasks. First we set the project paths at the top of the file. Followed by the paths we call targets, here we are calling CheckOut, Change, and finally CheckIn "VersionFile.cs" targets. During CheckOut we declare the Project Path that the VersionFile.cs is located, CheckOut that file using the CheckOut and FileSet tasks. Then we wrote an executable that changes the version number, and finally we use the VaultCheckIn and FileSet tasks to check the VersionFile.cs back into Valut. So what is happening is if the VersionFile.cs is checked in and the task checks it out, when it comes time to check it back in the error I copied in above occurs. If we then rerun the file without manually checking the VersionFile.cs back in before the CheckIn works fine. So there must be something occurring during the CheclOut that stops the file from being checked in again. The example I copied in above is the exact tasks we use in the exact order we use them, this should be enough info to discover the problem. Again, the sooner the better, we are trying to release 2 versions this week and we NEED this script to be working ASAP. Thank you very much for all the help and I hope to hear from you soon. Thanks again. Joe

shannon

Post by shannon » Wed Jul 25, 2007 9:47 am

Thank you for your patience. I've reproduced this and I have a fix and a workaround.

The fix will be in the 4.0.3 release.

In the meantime, I have this workaround: if you call vaultlistcheckouts between your vaultcheckout and vaultcheckin calls it should detect the checkout and checkin properly.

Sorry for the trouble you've had with this.

Post Reply