Explore Courses Blog Tutorials Interview Questions
0 votes
in Azure by (45.3k points)

I use Azure DevOps to schedule jobs on Azure Batch AI. Launching of jobs works great, I have python code that does the same.

What I am trying to achieve is that all jobs in the Batch AI experiment should be terminated when the build is canceled. Currently, canceling the build doesn't affect the run status of the Batch AI jobs.

Hence, is there a sort of "OnCancel" event to hook on to in the build to run a command (which will be python code to terminate all jobs)?

1 Answer

0 votes
by (16.8k points)

There is no need to look for an event, as a pipeline task can be configured to execute where the build was cancelled.

Note: this applies (as far as I am aware) to any task of the pipeline:

Run this task

Specifically, the Run this task setting, under Control Options will let you dictate when and under what conditions a task will run.

In the example above, this task will execute even if previous tasks fail, and even if the build was canceled.

In your case, I would place this as the last task that will perform the cleanup that you want, regardless of the outcome of the build.

Browse Categories