Cleanup after build failures

I am looking for my nant build script to be able to clean up after myself if the build goes wrong. I am looking for something similar to the following execution:

Target= Software.Build

Target= Software.Build.Success *(depends on Software.Build succeeding)*

Target= Software.Build.Failed

I am looking for a solution that if the Software.Build target does not work, then Software.Build.Failed will be launched, for example. to send someone a message that the assembly didn’t work in some way, otherwise Software.Build.Success will be launched to continue the script construction.

Is this possible with nant? If so, can someone point me to a suitable article / solution?

+3
source share
2 answers

NAntContrib has a tasktrycatch

<trycatch>
  <try>
    <call target="Software.Build" />
  </try>
  <catch>
    <call target="Software.Build.Failed" />
    <fail message="build failed" />
  </catch>
  <finally>
    <!-- execute everything that doesn't depend on success or failure -->
  </finally>
</trycatch>
<call target="Software.Build.Success" />
+4
source

, NAnt OnFailure.

<property name="nant.onfailure" value="failure" />
<target name="failure">
    <!-- Put your cleaning code in here -->
</target>
+6

Source: https://habr.com/ru/post/1767346/


All Articles