Danny Parker
Danny Parker

Reputation: 1773

Running scripts on a TeamCity server after an agent build has completed

We have one TeamCity server running on a mac, we have multiple agents running on mac and windows that do different types of builds.

Although the builds themselves are different (build with xcode/build with msbuild), there are a bunch of scripts at the end of each configuration that are the same. They involve copying files to a specific network share, notifying team members, and a few other things.

What would be great is if I could run the platform specific tasks on the respective build agent, but have the actual server run the final scripts after that.

The reason for this is to avoid writing everything in both bash and batch files (I can write it for the server, and make sure it has any dependancies), but also if we wanted to hook up an audio/visual/physical alert for a build fail, the script that runs that should only run on the server (no speakers/lights/nerf cannon on the agents).

Any ideas how I can easily setup a script to run on the server itself, and pass in the properties from the build?

Does this require a plugin, can I do something with the dependancy system, or do I need to delve into the REST API and trigger other configurations that way?

Upvotes: 1

Views: 1417

Answers (1)

Danny Parker
Danny Parker

Reputation: 1773

The solution we came to in the end was to use Meta-runners with a Python Runner. This allows us to have cross-platform python scripts that we can setup using the Team City variables. It also allows us to use these scripts in multiple configurations.

If anyone is looking to do this themselves, the platform module in python is useful if you still need to do some platform specific things in your script.

For example the following code allows us to us to use network share paths already setup on the build agents:

if platform.system() == 'Windows':
    network_folder = "//server_pc/builds"
else:
    network_folder = "/Volumes/builds"

Upvotes: 1

Related Questions