How to Define Deploy and Clean Pipelines for a Specific Environment?
To define a custom deploy/clean pipeline, you need to create TriggerTemplate, Pipeline, and Task.
More details are provided in the Customize Environment Cleanup and Customize Deploy Pipeline pages.