Search code examples
jenkinsnotificationstimeoutjenkins-pipelinedeclarative

jenkins pipeline options timeout and then notify


I have made use of

options {
        timeout(time: 10, unit: 'MINUTES') 
    }

But I would like to be able to have an action on timeout eg slackNotification etc

Is there any way to achieve this


Solution

  • Use post section and aborted condition as your pipeline is aborted on timeout. You can add some more logic within aborted condition to only execute your action on aborts that occurred due to timeout and not due to user manual abort for example.

    post { 
        aborted{ 
            // action on timeout
        }
    }