• Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

      It would be good to have the ability to run after scripts for stopped builds for cases where a Pipeline build triggers steps that start a deployment to a server, for example.

      Once a build is stopped on Bitbucket Pipelines, it would be good to be able to automatically trigger steps to cancel the build on the server too. The after-script function seems to be the best approach for this.

       

      Edit: An additional suggestion - Execute after script in situations where build stops after max-time as well. 

            [BCLOUD-19866] Run after-script scripts for stopped builds

            if a job is manually cancelled while waiting for an external api process to run, we want to cancel that process.  Currently it means logging into this external service, finding the process and cancelling it manually; which takes time and worse, can be forgotten; leaving the job running

            Steven Hayhurst added a comment - if a job is manually cancelled while waiting for an external api process to run, we want to cancel that process.  Currently it means logging into this external service, finding the process and cancelling it manually; which takes time and worse, can be forgotten; leaving the job running

            Without this, stopping a particular kind of build forces the runner into an UNHEALTHY state.

            I am running a Yocto/OE script in a pipeline on a self-hosted linux shell runner. The build leaves a lot of stuff in the work directory that needs manual cleanup. An after script handles this for builds run to success or failure just fine. But if the build is stopped from Bitbucket, the cleanup script is not run and the runner fails to clean up the work directory. Manual intervention is then required to get the runner back to ONLINE status.

            I will be developing a workaround for my issue because Atlassian moves at a glacial pace.

             

            Aaron Heise added a comment - Without this, stopping a particular kind of build forces the runner into an UNHEALTHY state. I am running a Yocto/OE script in a pipeline on a self-hosted linux shell runner. The build leaves a lot of stuff in the work directory that needs manual cleanup. An after script handles this for builds run to success or failure just fine. But if the build is stopped from Bitbucket, the cleanup script is not run and the runner fails to clean up the work directory. Manual intervention is then required to get the runner back to ONLINE status. I will be developing a workaround for my issue because Atlassian moves at a glacial pace.  

            +1. This feature would be really useful because we would be able to clean up our resources better if our build fails or is stopped. This feature would ensure that we never end up in a half-deployed state and would put us in a position when we can rely even more on the cloud for deployments. 

            Kerishini Venketroyalu added a comment - +1. This feature would be really useful because we would be able to clean up our resources better if our build fails or is stopped. This feature would ensure that we never end up in a half-deployed state and would put us in a position when we can rely even more on the cloud for deployments. 

            +1 Having the ability to run an after-script would have made it possible for us to pick up a lot of post-deployment issues!

            Van Reenen de Waal added a comment - +1 Having the ability to run an after-script would have made it possible for us to pick up a lot of post-deployment issues!

            +1. Would be good to be able to define after-scripts for failed steps and separately for failed OR manually-stopped steps, depending on specific needs of the user.

            Witold Smaga added a comment - +1. Would be good to be able to define after-scripts for failed steps and separately for failed OR manually-stopped steps, depending on specific needs of the user.

            Mladen added a comment -

            This feature would be extremely useful in any situation where you use an After Script. Often you want to do the same cleanup even if the pipeline was stopped, not just when it failed.

            Mladen added a comment - This feature would be extremely useful in any situation where you use an After Script. Often you want to do the same cleanup even if the pipeline was stopped, not just when it failed.

            +1

            we need to call a custom cleanup function

            Petr Gotthard added a comment - +1 we need to call a custom cleanup function

            An additional use case: the inability to handle cleanup steps when a pipeline is stopped is a real problem for any case where partial completion has a negative impact. For example, when running Terraform, if a pipeline is stopped at the wrong time, resources may be created without being persisted to the state file. Having a hook that we could tie into in these cases would be a significant step forward.

            Brian Shacklett added a comment - An additional use case: the inability to handle cleanup steps when a pipeline is stopped is a real problem for any case where partial completion has a negative impact. For example, when running Terraform, if a pipeline is stopped at the wrong time, resources may be created without being persisted to the state file. Having a hook that we could tie into in these cases would be a significant step forward.

            +1 
            please create more events like after-script, so it would be more flexible to manage pipelines.

            Simonas Jurksa added a comment - +1  please create more events like after-script, so it would be more flexible to manage pipelines.

            +1
            We need a way to send notification when build is manually stopped.

            Samir Shaik added a comment - +1 We need a way to send notification when build is manually stopped.

              Unassigned Unassigned
              ggattino Gustavo Gattino (Inactive)
              Votes:
              74 Vote for this issue
              Watchers:
              30 Start watching this issue

                Created:
                Updated: