Errors running tests via TCM as part of a Release Management pipeline

Whilst getting integration tests running as part of a Release Management  pipeline within Lab Management I hit a problem that TCM triggered tests failed as the tool claimed it could not access the TFS build drops location, and that no .TRX (test results) were being produced. This was strange as it used to work (the RM system had worked when it was 2013.2, seems to have started to be issue with 2013.3 and 2013.4, but this might be a coincidence)

The issue was two fold..

Permissions/Path Problems accessing the build drops location

The build drops location passed is passed into the component using the argument $(PackageLocation). This is pulled from the component properties, it is the TFS provided build drop with a appended on the end.

image  

Note that the in the text box is there as the textbox cannot be empty. It tells the component to uses the root of the drops location. This is the issue, as when you are in a network isolated environment and had to use NET USE to authenticate with a the TFS drops share the trailing causes a permissions error (might occur in other scenarios too I have not tested it).

Removing the slash or adding a . (period) after the fixes the path issue, so..

  • \serverDropsServices.ReleaseServices.Release_1.0.227.19779        -  works
  • \serverDropsServices.ReleaseServices.Release_1.0.227.19779      - fails 
  • \serverDropsServices.ReleaseServices.Release_1.0.227.19779.     - works 

So the answer is add a . (period) in the pipeline workflow component so the build location is $(PackageLocation). as opposed to $(PackageLocation) or to edit the PS1 file that is run to do some validation to strip out any trailing characters. I chose the later, making the edit

 1if (\[string\]::IsNullOrEmpty($BuildDirectory))  
 2    {  
 3        $buildDirectoryParameter = \[string\]::Empty  
 4    } else  
 5    {  
 6        # make sure we remove any trailing slashes as the cause permission issues  
 7        $BuildDirectory = $BuildDirectory.Trim()  
 8        while ($BuildDirectory.EndsWith(""))  
 9        {  
10            $BuildDirectory = $BuildDirectory.Substring(0,$BuildDirectory.Length-1)  
11        }  
12        $buildDirectoryParameter = "/builddir:""$BuildDirectory"""   
}  

   

 1
 2### Cannot find the TRX file even though it is present
 3
 4Once the tests were running I still had an issue that even though TCM had run the tests, produced a .TRX file and published it’s contents back to TFS, the script claimed the file did not exist and so could not pass the test results back to Release Management.
 5
 6The issue was the call being used to check for the file existence.
 7
 8> **\[System.IO.File\]::Exists($testRunResultsTrxFileName)**
 9
10As soon as I swapped to the recommended PowerShell way to check for files
11
12> **Test-Path($testRunResultsTrxFileName)**
13
14it all worked.