jenkinsci / jenkinsci/workflow-basic-steps-plugin

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

Đang mở
#413 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
component:workflow-basic-steps-plugin imported-jira-issue priority:minor resolution:unresolved
Ngôn ngữ chính
Java
Star
73
Fork
129
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với bước timeout của Jenkins Pipeline và tái hiện sự cố bằng ví dụ Groovy được cung cấp với docker-compose. Theo dõi cách timeout xử lý một lệnh đã kết thúc với trạng thái 0; được xem là hoàn tất khi timeout phát sinh lỗi và echo phía sau không được thực thi, với phần bao phủ cho hành vi này.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
docker-compose, java
Lĩnh vực
ci-cd, devops
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.