run batch file when agent runs

we have the source control (subversion) on a server (at a client site) that can only be accessed through vpn connection. I have a batch file available to open the vpn connection and to signout/terminate vpn connection. I can't access the build server (virtual machine) when the vpn connection is active because of the vpn settings and i dont have any control over the vpn. so, if we run the vpn connection all the time, then we can't access the teamcity site or login to the build server, unless we walk over to the server room and access the host server manually to login to the build server and kill the vpn connection.

So, ideally, i want the buildagent to run a command (batch file) to open the vpn connection before it connects to subversion, then go through usual steps, like checking source control for changes, build, label, etc, and then after it's done, to terminate the vpn connection.
Is there a way to accomplish this?
Thanks
Kannan

5 comments
Comment actions Permalink

Hi Cannan

VPN on a build agent is not enough. TeamCity server needs a connection to your VCS too - to monitor and show commits, source diffs, etc.

Usually a routing can be configured to allow all connections simultaneously. If you use built-in Windows VPN client then this option is hidden inside tcp/ip settings
Capture.PNG

Michael

0
Comment actions Permalink

we use Juniper network connect for vpn client. The VPN settings on the server side is beyond our control. The moment we establish vpn connection, our LAN is not accessible (printer, other servers, etc). so, i want to establish the vpn connection, before build agent connects to vcs (say every 5 minutes) and terminate the vpn after build agent is done with its work.
Currenlty, the only way i can accomplish this is to use schedule trigger to trigger build every 30 or 60 minutes and schedule in task scheduler to start and stop vpn around the build window (start vpn couple of minutes before the build gets triggered and stop vpn after 10 minutes). I trying to find out if there is a better way, i.e. build agent can take care of starting and stopping vpn connection using batch file or powershell script or is there a way to write a plugin?
thanks
kannan

0
Comment actions Permalink

I want to make sure I understand your environment correctly.
Does TeamCity web server have continuous access to the version control server?

This is absolutely required. With default settings (server-side checkout) your build agents can have no access to VCS at all - the server works as a proxy.
But opposite scheme is not possible - the server needs to have permanent access to VCS in all the scenarios.

Michael

0
Comment actions Permalink

so you are saying the options are either continuosly have the vpn connection running or use in-house source control that mirrors the source control at client's location, so that it would be able to connect to source control at all times?

0
Comment actions Permalink

yes, it's required

0

Please sign in to leave a comment.