Uploaded image for project: 'Jenkins Artifactory Plug-in'
  1. Jenkins Artifactory Plug-in
  2. HAP-1229

Error in retry upload leads to `currentBuild.result` set to `FAILURE`, which always break the job

    XMLWordPrintable

    Details

      Description

      https://github.com/jfrog/jenkins-artifactory-plugin/issues/133

      I got the problem, that Conan fails, because he got an error '500', when uploading a package.
      Unluckily Conan is (at the moment) not retrying the task, as I put him on the commandline arguments.

      So I wrote the following groovy script for Jenkins Pipeline:

              // Upload to Conan (Artifactory)
              // It happens sometimes, that 2 processes try to change the same value at the same moment. Therefor we repeat the step.
              def max_retry_upload = 5
              for (i = 0; i <max_retry_upload; i++) {
                  try {
                      client.run command: "upload * --all --force --retry 5 --retry-wait 10 -r ${name} --confirm".toString(), buildInfo: buildInfo
                      break
                  }
                  catch(Exception e) {
                      if (i == max_retry_upload - 1) {
                          println "Current Build result: ${currentBuild.result}"
                          println "Error: Unable to upload, sthrow exception..."
                          throw e
                      }
                      else {
                          println "Current Build result: ${currentBuild.result} (Change status back to SUCCESS)"
                          println "Warning: Unable to upload, sleep & retry..."
                          currentBuild.result = 'SUCCESS'
                          sleep(5 + 5 * Math.random()) // Wait 5 to 10 seconds
                      }
                  }
              }
      
      

      The script is working, so that Jenkins build the job (also when the first upload fails). But unluckily he still recognize the first error in the upload as error of the complete job. I thought, when I catch the error, he should ignore the failure. The "currentBuild.result" is already set to "FAILURE" instead of "SUCCESS".
      Could it be, that the Artifactory plugin first catch the error, then set "currentBuild.result" to "FAILURE" and then rethrow the execption?

      May be it would be fine, if we have an extra flag to let the artifactory plugin just not to write theĀ currentbuild.result?

        Attachments

          Activity

            People

            Assignee:
            yahavi Yahav Itzhak
            Reporter:
            climblinne Jan Linnenkohl
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: