Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-20370

CopyArtifact - get last artifact from self

    Details

    • Similar Issues:

      Description

      I try to get the artifacts from the last job where the job is the same as before (itself) without relying on leftovers in the workspace and without chaining the job to itself.

      The job might fail or pass but I would need the artifacts from the last execution. However, when I pick the option permlink->lastBuild then this won't contain any artifacts because the current running job is already linked to lastBuild. Adding two CopyArtifact jobs one for permaLink->lastFailedBuild and one for permaLink->lastSuccessfulBuild collects twice the artifacts and I need to decide which to pick.

      My current implementation within the job looks like:

      1. get build number of last failed build
        open(ENV['JOB_URL']+"/lastFailedBuild/buildNumber") do |lastFailedBuildNumberPage|
        lastFailedBuildNumberPage.each_line do |line|
        @lastFailedBuildNumber = line.to_i
        end
        end
      2. get build number of last successful build
        open(ENV['JOB_URL']+"/lastSuccessfulBuild/buildNumber") do |lastSuccessfulBuildNumberPage|
        lastSuccessfulBuildNumberPage.each_line do |line|
        @lastSuccessfulBuildNumber = line.to_i
        end
        end
      3. get artifacts from most recent build
        if @lastFailedBuildNumber > @lastSuccessfulBuildNumber
        open(ENV['JOB_URL']@lastFailedBuildNumber.to_s"/artifact/job.txt/view/") do |lastFailedArtifactsPage|
        lastFailedArtifactsPage.each_line do |line|
        @lastFailedArtifactsPage << line.chomp!
        end
        end
        else
        open(ENV['JOB_URL']@lastSuccessfulBuildNumber.to_s"/artifact/job.txt/view/") do |lastSuccessfulArtifactsPage|
        lastSuccessfulArtifactsPage.each_line do |line|
        @lastSuccessfulArtifacts << line.chomp!
        end
        end
        end

      Could this logic get implemented within the plugin?

        Attachments

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              Unassigned
              Reporter:
              robsimon robsimon
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: