Run a Script/Step if Deployment is canceled

I want to run a script only in case if we cancel the deployment. how we can do it ?

Mean if i cancel a deployment then the script should be triggered and if the deployment is fail/success then no need to trigger it.

Hi, I need this urgent . can someone please look into it.

Hi mohitmishra.mishra1989,

Thanks for reaching out!

It sounds like you are probably looking to accomplish something different, just a reminder that Octopus has email and webhook notifications available via Subscriptions in the Configuration tab.

If you don’t mind me asking, what is the purpose of the script you want to trigger on a cancelled task/deployment?

Regards,
Donny

Hi, Here is the scenario and my requirement.

  1. I have multiple projects for example Project-A, Project-B and Project-C
  2. Whenever we run project Project-A, it stops the services of Project-B and Project-C.(Services created during the deployment of project -B and Project-C) As it’s a pre-requsites, so the process of Project-A is Stop service, deploy project-A packages and then start the services of project A and B.
  3. By default, whenever we deploy project-B or project-C, after the deployment it starts the services of Project-B and Project-C, but if a deployment of Project-A is running or in progress , Deployment step of Project-B and Project-C skips the starting of services.
  4. Issue occur when we cancel the Project-A deployment in between and due to that services get impacted. To resolve this we have to either manually start the services or re-deploy the project-B and Project-C.

corrected 2nd line…

  1. Whenever we run project Project-A, it stops the services of Project-B and Project-C.(Services created during the deployment of project -B and Project-C) As it’s a pre-requsites, so the process of Project-A is Stop service of project-B and Project-C, deploy project-A packages and then start the services of project-B and Project-C.

Hey mohitmishra.mishra1989,

Thanks for the explanation. It makes sense what you are trying to accomplish. After brainstorming with my team, it looks like using webhooks with the task canceled event would be the only way to truly automate this process for the moment. We are planning to incorporate additional functionality with Runbooks that should make this much easier in the future. Keep an eye on our new releases.

For the time being, would it be feasible to create a simple project with a script to turn on the services that were turned off due to the canceled task? In the event of a canceled task, just re-deploy the release after canceling.

Let me know what you think.

Regards,
Donny

For Webhooks we need to create a API endpoint and we also don’t want to create a another project and ran it manually whenever we cancel any deployment.

Is there any way we can re-route the webhooks post request to hit the octopus server it self and ran a new project automatically ?

just like through REST API we can create and deploy a project in octopus.

Hi mohitmishra.mishra1989,

This is currently not possible until our Runbooks upgrade that I mentioned previously is released.

I’m sorry, I know this isn’t the answer you wanted. I’m hopeful that this will be available soon. Be sure to keep an eye on our new versions so that you can take advantage of the new functionality as soon as possible. You are also welcome to check in with me at any time by replying to this thread or sending me a PM. :smile:

If there is anything else I can assist with, please let me know.

Regards,
Donny