jenkinsci / jenkinsci/workflow-basic-steps-plugin

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

Aperta
#413 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
component:workflow-basic-steps-plugin imported-jira-issue priority:minor resolution:unresolved
Lingua principale
Java
Stelle
73
Fork
129
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.