jenkinsci / jenkinsci/workflow-basic-steps-plugin

[JENKINS-55958] Allow executing additional action in timeout step before wrapped steps will be cancelled

Open
#483 2 comments 0 reactions 0 assignees View on GitHub
component:workflow-basic-steps-plugin imported-jira-issue priority:major resolution:unresolved
Dominant language
Java
Stars
73
Forks
129
PR merge metrics
No merged PRs in 30d

Description

It would be very useful to allow users to define additional steps which will be executed on timeout, but before the processes will be stopped. For example in our case we want to generate threaddump.log and dump.hprof files when the executed Java logic is frozen. It is possible to do it by using Time-out actions provided by Build Timeout plugin. Unfortunately, I cannot use it with Jenkins Declarative Pipelines.

timeout(time: 30, onTimeout: {

sh """#!/bin/bash
echo "Performing thread dump"
for pid in \$(ps auxwwe | grep APPLICATION_ID | grep -v grep | grep BUILD_ID=${env.BUILD_ID} | awk '{print \$2}'); do
echo "thread dump of \$pid"
jstack \$pid > threaddump_\$pid.log
done
"""
}) {
sh "mvn verify"
}

---
Originally reported by agabrys, imported from: Allow executing additional action in timeout step before wrapped steps will be cancelled


  • status: Open
  • priority: Major
  • component(s): workflow-basic-steps-plugin
  • resolution: Unresolved
  • votes: 2
  • watchers: 2
  • imported: 20251215-220547

Raw content of original issue

It would be very useful to allow users to define additional steps which will be executed on timeout, but before the processes will be stopped. For example in our case we want to generate threaddump.log and dump.hprof files when the executed Java logic is frozen. It is possible to do it by using Time-out actions provided by Build Timeout plugin. Unfortunately, I cannot use it with Jenkins Declarative Pipelines.



timeout(time: 30, onTimeout: {

sh """#!/bin/bash
echo "Performing thread dump"
for pid in \$(ps auxwwe | grep APPLICATION_ID | grep -v grep | grep BUILD_ID=${env.BUILD_ID} | awk '{print \$2}'); do
echo "thread dump of \$pid"
jstack \$pid > threaddump_\$pid.log
done
"""
}) {
sh "mvn verify"
}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.