Ask Your Question
2

How can I make Jenkins indicate an error and switch the build status to FAILED after a timeout is reached?

asked 2021-11-16 11:00:00 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-10-05 11:00:00 +0000

ladyg gravatar image

Jenkins has a built-in timeout feature that can be used to mark a build as failed if it takes too long to complete. Here are the steps to set a timeout and mark the build as failed once the timeout is reached:

  1. Open the Jenkins job configuration page.
  2. Scroll down to the "Build" section and click on "Add build step" or "Add post-build action" depending on where you want to set the timeout.
  3. Select "Execute shell" or "Execute Windows batch command" depending on your environment.
  4. Enter the command you want to run and add the following line at the end:
timeout 60 || exit 1

This will cause the build to fail if it takes more than 60 seconds to complete.

  1. Save the job configuration and run a build.

Now, if the build takes longer than 60 seconds, it will be marked as failed and the status will change to "FAILED".

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-11-16 11:00:00 +0000

Seen: 8 times

Last updated: Oct 05 '22