How to run command line steps on both OSX and Windows

We have a mix of different build agents, both OSX and Windows. Some of our builds require execution of command line steps.

Is it possible to have a single build configuration with command line build steps that will be able to execute on both agent types?

Just to give a silly example, the command 'rm -rf %some path%' will run on the OSX agent, but not on the Windows agent.

I know it is possible to duplicate the configuration and set a condition to run on a particular OS and modify the build steps per platform, but i am looking for a simpler solution.

0
2 comments
Avatar
Permanently deleted user

Hi,

maybe you could install gow (https://github.com/bmatzelle/gow/wiki) on your windows agent ?

It's a set of unix commands for windows (so 'rm -rf %some path%' will run also on your windows agent).

In case you want to use some condition you can use 'test' (test 0 -eq 0 && echo "if test is true" || echo "if test is false")

Note: it's not a unix bash; there is missing commands, some are renamed ('gfind' instead of 'find'),  (if [ $toto -eq 0]; then echo "do something")

0

Thanks for the suggestion. i will look into that.

I thought of another solution although i am not sure it's as optimal. What if the build scripts were part of the repo? The TeamCity build process would simply invoke the relevant script (e.g: batch file / powershell on Windows, shell script on OSX).

I've seen many open source projects that have a build script at their root level, so i assume this is a common practice, although you do lose the ability of keeping the scripts outside of your repo and being able to modify them without any additional commits to source control.

0

Please sign in to leave a comment.