Running batch file which calls an external exe

Hi,

I'm currently trying to run a Team City build task for a Java GUI Application which I'm packaging with Excelsior Jet. Jet provides a batch file which will build the executable prior to packaging. I'd like to call this from Team City so that it gets the latest code, compiles it and creates the exe.

So far it gets the code (from Perforce) and compiles it ok, and the first two times I ran it it actually worked (the part that doesn't work now). My ant file itself works fine and can be called from a command line and it will run the batch file. However when I let Team City run it, it doesn't recognise the exe that the batch file is calling (...jc is not regognized as an internal or external command).

This is the extract from the ant file, which works fine on it's own but not through Team City...

]]>

The batch file contains a call to "jc.exe", the Jet compiler. This is what Team City doesn't seem to recognise.

I've tried setting the path to the executable (in the batch file) but that doesn't help. It seems Team City itself wants to know the path, which I can't understand.

Would much appreciate any suggestions.

Cheers,

Doug

9 comments
Comment actions Permalink

Managed to get around it by using the full path to jc in the batch file. Not an ideal solution but it looks as though the batch file won't change much (it's outputted by Jet every build), it's the Jet project file that will change.

0
Comment actions Permalink

Having got round that problem, I now have the same problem as before trying to call an executable for JetPackII (installer creation with Excelsior Jet). I used the same full path to the command, but there's an exe that gets called by that in a different directory, so basically I can't prepend the path to it because there's nowhere to put it. So now I'm stuck, the Ant task works perfectly, but TeamCity is unable to call it.

Can anyone help with this? Do I need to specify these paths in Ant for TeamCity to recognise it? Am I missing something in the configuration of the TeamCity task?

Cheers,

Doug

0
Comment actions Permalink

Also, I've tried putting the path required into the System PATH, but the script (when run in TeamCity) doesn't seem to pick this up.

0
Comment actions Permalink

Hello,

Try providing PATH variable using conf/buildAgent.properties file of the buildAgent. Use syntax like
env.PATH=]]>

Hope this helps,
KIR

0
Comment actions Permalink

Hi Kirill,

Thanks for you response. I tried your suggestion but still no luck. I stopped both build agent and team city server services, added the PATH variables as follows...

env.PATH=D\:
dev
bin
excelsior
jet
4.8
bin;D\:
dev
bin
excelsior
jet
4.8
profile1.5.0_09
develop
bin;

I also tried them in the normal filepath format without the escape characters but it still doesn't recognise the Jet executable calls. I added the escape characters as shown as the classpath used those.

Thanks,

Doug

0
Comment actions Permalink

I've submitted a support form about it, I'll post the results if/when I get things working.

Cheers

0
Comment actions Permalink

Hi again,

been in touch with Support and the solution was that the Windows Service running Team City (specifically the buildAgent service) needed to be set up for a user account rather than the standard "Local Service". Otherwise it couldn't access the System paths.

Cheers,

Doug

0
Comment actions Permalink

Hello,

I tried to reproduce your problem, but in my case both approaches worked fine:

One is including folder with the executable in the global system PATH environment variable (The machine should be restarted after changing Environment Variables in System Properties/Advanced so that updated values take effect.)

Another is modifying the PATH variable inside the .bat file (that is called from the ant task).

In both cases all the child processes got the modified PATH and were able to find the executable.

You can try to invoke "set PATH" command in your buildExecutable.bat file to see if it includes all the necessary folders in the PATH.

It seems to be some environment issue. Please let us know if you find out more details on it.

--
Best regards,

Yegor Yarko
Quality Assurance Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Hi Yegor, thanks for looking into the problem. I did try putting the path into the batch file but that wouldn't work. It seems to be purely because the buildAgent is running as a service using the standard local login. Assigning the admin user login to the service solved the problem.

Cheers,

Doug

0

Please sign in to leave a comment.