jenkinsci / jenkinsci/workflow-basic-steps-plugin

[JENKINS-39187] Pipeline timeout should still raise an error if a terminated shell command exits normally

オープン
#413 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
component:workflow-basic-steps-plugin imported-jira-issue priority:minor resolution:unresolved
主要言語
Java
スター
73
フォーク
129
PR マージ指標
30日以内にマージされた PR はありません

説明

The timeout pipeline step will send an TERM signal to an inner process when its time window ends. If that inner process is listening for TERM and exits normally when it sees one - it seems that no other error appears in the jenkins pipeline. Later tasks within the `timeout` block still execute and no exception is caught by the pipeline.

I hit this by running docker containers in docker-compose wrapping `python -m unittest` - all combined that ends up exiting with code 0 on termination.

I expect I can work around this, but the behavior seemed unexpected enough (timeout followed by ... no errors) to file this issue.

Update: looks like (in this case) the behavior comes from `docker-compose exec`.

as a workaround I'm able to use `docker exec` which returns non-zero when terminated.

example groovy step:

timeout (time: 1, unit: 'SECONDS') {

sh 'docker-compose alpine sleep 10'
echo('sleep complete (should not get here)')
}

docker-compose:

version: '2'

services:
alpine:
image: alpine
command: bash
tty: true

---
Originally reported by jett_bonsai, imported from: Pipeline timeout should still raise an error if a terminated shell command exits normally


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

Raw content of original issue

The timeout pipeline step will send an TERM signal to an inner process when its time window ends. If that inner process is listening for TERM and exits normally when it sees one - it seems that no other error appears in the jenkins pipeline. Later tasks within the `timeout` block still execute and no exception is caught by the pipeline.

I hit this by running docker containers in docker-compose wrapping `python -m unittest` - all combined that ends up exiting with code 0 on termination.

I expect I can work around this, but the behavior seemed unexpected enough (timeout followed by ... no errors) to file this issue.

Update: looks like (in this case) the behavior comes from `docker-compose exec`.

as a workaround I'm able to use `docker exec` which returns non-zero when terminated.

example groovy step:



timeout (time: 1, unit: 'SECONDS') {

sh 'docker-compose alpine sleep 10'
echo('sleep complete (should not get here)')
}

docker-compose:



version: '2'

services:
alpine:
image: alpine
command: bash
tty: true

  • environment: Jenkins 2.25; Pipeline 2.2; Pipeline: Basic Steps 2.2; Pipeline Nodes and Processes 2.5; Pipeline: Supporting Apis 2.10

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。