Using timeout as a section vs an option

19 views
Skip to first unread message

Sagar Patel

unread,
Aug 18, 2021, 9:13:53 AM8/18/21
to Jenkins Users
Hi,

Is there any difference between the timeout section and the timeout option? For example, are

stage('Test') {
  timeout (time: 1, unit: 'HOURS') {
    steps {
      ./test.sh
    }
  }
}

and

stage('Test') {
  option { timeout (time: 1, unit: 'HOURS') }
  steps {
    ./test.sh
  }
}

equivalent?

Jenkins version: 2.289.3

Thanks,
—Sagar

Sagar Patel

unread,
Aug 18, 2021, 7:27:11 PM8/18/21
to Jenkins Users
I'm observing that the former can incorrectly indicate that the stage passed when in fact it was aborted/terminated due to timeout. The latter doesn't have this bug.

Has anyone seen this before?

—Sagar

Sagar Patel

unread,
Aug 18, 2021, 7:29:29 PM8/18/21
to Jenkins Users
Actually, I mistyped. The former should be

stage('Test') {
  steps {
    timeout (time: 1, unit: 'HOURS') {
      sh './test.sh'
    }
  }
}

That is, the position of steps and timeout are swapped. Does this have a practical difference?

Thanks,
—Sagar
Reply all
Reply to author
Forward
0 new messages