Problems using retry() when failures occur in pipeline

11 views
Skip to first unread message

Mike Kingsbury

unread,
Aug 31, 2016, 11:19:31 AM8/31/16
to Jenkins Users
I have a fairly simple block of code we run to update a system, that occasionally fails due to problems outside our control.  I thought this would be a great place to wrap it in a retry block.  The problem I have is that even though the retry block is successful later on, it fails the build at the end due to the earlier failure. I also tried unsuccessfully to wrap this in a try/catch without much luck.  Any suggestions on how to not fail a build if the retry block is successful? (I may just pull this out into a separate shell script at this point...)



    int retry_count = 0
   
retry(25){
     
if ( retry_count != 0 ) {
        sleep
(10)
     
}
      retry_count
++
      sh
'sudo apt -y autoremove'

      sh
'sudo apt-get update'
      sh
'sudo apt-get -y -f upgrade'
      sh
'./make-deps.sh'
   
}


Reply all
Reply to author
Forward
0 new messages