-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
Jenkins 2.150.3
This is the pipeline code I have tried to reproduce this potential issue:
node { timeout(time: 2, unit: 'SECONDS') { retry(2) { parallel( a: { build job: 'Child_Job', parameters: [ string(name: 'Param1', value: 'Val1'), string(name: 'Param2', value: 'Val2') ] } ) } } }
Even after timeout of 2 seconds is over (which I thought would be timeout for attempts including retries), the second retry attempt happens anyways and the child job runs indefinitely.
This is the console log:
[Pipeline] node Running on Jenkins [Pipeline] { [Pipeline] timeout Timeout set to expire in 2 sec [Pipeline] { [Pipeline] retry [Pipeline] { [Pipeline] parallel [Pipeline] [a] { (Branch: a) [Pipeline] [a] build (Building Child_Job) [a] Scheduling project: Child_Job Cancelling nested steps due to timeout [Pipeline] [a] } [a] Failed in branch a [Pipeline] // parallel [Pipeline] } ERROR: Build of Child_Job was cancelled Retrying [Pipeline] { [Pipeline] parallel [Pipeline] [a] { (Branch: a) [Pipeline] [a] build (Building Child_Job) [a] Scheduling project: Child_Job Body did not finish within grace period; terminating with extreme prejudice [Pipeline] [a] } [a] Failed in branch a [Pipeline] // parallel [Pipeline] } [Pipeline] // retry [Pipeline] } [Pipeline] // timeout [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline Timeout has been exceeded Finished: ABORTED
When I handle the exception of child job, this error (ERROR: Build of Child_Job was cancelled) is caught and handled. Retry does not happen in that case.
Please note that if I use sleep(time:3,unit:"SECONDS") instead of "build job" step, the retry attempt does not happen. So, it could be something to do with retry block catching the child-job's cancelled exception (which is caused by timeout) and attempting a retry in-spite of it being inside a timeout block which has already timed out.
With the timeout block within retry block, the timeout is applicable for each attempt or retry separately. So if I set timeout as 2 seconds, 2 seconds is timeout for each time code block executes in retry block. I am actually looking to apply consolidated timeout for all attempts in retry block. 2 seconds as timeout for all attempts including retries. Of course 2 seconds as timeout is only for reproducing the issue.
Please correct me if I am wrong. The above is based on my analysis so far but I usually work on other programming frameworks, So I have very limited knowledge on pipeline framework. Tried asking first in [StackOverflow|https://stackoverflow.com/questions/61053844/jenkins-pipeline-retry-happens-even-after-timeout].