jenkinsci / jenkinsci/workflow-basic-steps-plugin

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

Abierto
#413 0 comentarios 0 reacciones 0 asignados Ver en GitHub
component:workflow-basic-steps-plugin imported-jira-issue priority:minor resolution:unresolved
Lenguaje dominante
Java
Estrellas
73
Forks
129
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Start with the Jenkins Pipeline timeout step and reproduce the issue using the supplied Groovy example with docker-compose. Trace how timeout handles a terminated command that exits with status 0; done means the timeout raises an error and the later echo does not execute, with coverage for this behavior.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
docker-compose, java
Área
ci-cd, devops
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.