Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can an ANT build script kill a Windows process?

I'm working on extending an ANT build script to allow a TeamCity build agent to run Selenium tests.

In doing so there is a server required to start with selenium which isn't shutdown at the end. So I added an extra target to execute a taskkill on the exe name at the end of every TC build.

Does taskkill need the absolute path to the exe, because the following isn't working;

<target name="shutdown.server" depends="init.properties" description="Shutdown the server after Selenium">
    <exec osfamily="windows" executable="cmd.exe" spawn="true">
        <arg line="taskkill /f /t /im app.exe"/>
    </exec>
</target>

The process seems to have a few children which is why I've gone with /f /t but as I say, none of them shutdown at the moment.

like image 739
markwalker_ Avatar asked Mar 20 '13 08:03

markwalker_


People also ask

What is an ant build script?

Ant is a Java-based build tool created as part of the Apache open-source project. You can think of it as a Java version of make. Ant scripts have a structure and are written in XML. Similar to make, Ant targets can depend on other targets.

How do I run an Ant script in Windows?

To run the ant build file, open up command prompt and navigate to the folder, where the build. xml resides, and then type ant info. You could also type ant instead. Both will work,because info is the default target in the build file.


1 Answers

Well that was easy;

<target name="shutdown.server" depends="init.properties" description="Shutdown the server after Selenium">
    <exec executable="taskkill">
        <arg line="/im app.exe /f /t"/>
    </exec>
</target>
like image 105
markwalker_ Avatar answered Sep 17 '22 18:09

markwalker_