PVCS from vbscript via TeamCity Command line runner fails


We use TeamCity as our CI server, and are very happy with it.  I'm trying to integrate a home-grown tracking system that we use for, among other things, specifying SQL dependencies and apply order for builds.  The tracking system stores everything in MSSQL 2k, while version control is in PVCS.  Moving away from PVCS for these files is not an option at the moment.

I have written a vbscript that does a few things, etc etc, gets a list of files, and processes them.  It runs fine from the command line.  When run from the TeamCity Command Line Runner, it fails.  

I use two PVCS command line tools, vcs.exe to apply a promotion group, and pcli.exe to get the file, and apply a version label.  vcs.exe returns error code 1, pcli returns error code 3.  

Teamcity service and agent both run as 'teamcity', a domain user account.
v:\pvcs is mapped to the repository. teamcity user has been given full control
d:\build is a temp directory. teamcity user has been given full control

The PVCS client runs and works fine - sees the repository no problem.
PVCS command line tools are in the path and can be run no problem.  Looking at the agent environment in TeamCity, the path lists them there as well.

The code box lists some log output from team city.  When something fails, I output the cmdline that was trying to run.  I can copy and paste that and it will run successfully.
[11:23:29]: [AdminMiscellaneous.html] runCmd
[11:23:29]: [AdminMiscellaneous.html] Failure: Couldn't apply TEST promotion group. Code: 1; Command: vcs -cV:\PVCS\archives\ctpkppx1.cfg -#3 -Y -gTEST:1.6 v:\pvcs\archives\com\docs\html\AdminMiscellaneous.html
[11:23:31]: [AdminMiscellaneous.html] runCmd
[11:23:31]: [runCmd] 11:23:31 Feb.23.09 [Error]
[11:23:31]: [runCmd] The project root could not be loaded: "v:\PVCS".
[11:23:31]: [AdminMiscellaneous.html] Failure: Couldn't get AdminMiscellaneous.html. Code: -3; Command: pcli run -y get -prv:\PVCS -nm -ad:\build\pvcs -o -bp/ -r1.6 /com/docs/html/AdminMiscellaneous.html

Open in new window

Who is Participating?
purplepomegraniteConnect With a Mentor Commented:
You say that TeamCity runs as a service, and also that you are using mapped drives?  If the Command Line Runner is running in the context of the service, mapped drives are not available, so this will fail.

More info at: http://support.microsoft.com/kb/180362

Is this likely to be the problem?  If so, you could try changing all the paths to UNC - this should resolve it.
HecatonchiresAuthor Commented:
That... does not make me happy.  PVCS is required to run with a drive letter, under this configuration anyway and with this version anyway.  I'll do some poking on PVCS and see if I can access it using a UNC.  Leaving this open a little longer, but at the moment you're getting the points purple.  
After digging a little more, it seems that it is possible to map a drive in a service.  I have found many mentions of it but so far unfortunately the links to the code or working examples (outside VB or VB.Net) have disappeared.

One thing that does need to be done is for the service itself to map the drive.  A service runs in it's own session (even if it shares the user account), so any mapped drives are not available when the service starts.  However, it seems that it is possible to map the drive once the service is started...  But I just can't find any articles that show how this could be done from VBScript (apparently net use, etc. does not work).

That said, due to the KB article and MS's advice (there are loads of references saying services should use UNC not mapped drives), the best solution would be to find some way to get it to use UNC.
HecatonchiresAuthor Commented:
It's definitely the problem.  Already have 1 command working, the other looks like it will require some more fiddling.  Thanks for the help PP
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.