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

False positive on "expected x but caught y"

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • workflow-cps-plugin
    • None

      The code below seems to work, the files get copied as desired, but I can't seem to shake the error that something is wrong.  Of course, the problem is that it sets the job status to failure even though it works. 

      class CopyArtifactSteps {
      
       static void getLockfilesFromUpstream(CpsScript currentBuild) {
       getLockfilesFromUpstreamNonCps(currentBuild)
       }
      
       @NonCPS
       static void getLockfilesFromUpstreamNonCps(CpsScript currentBuild) {
       // It's not good, but we get have to validate that it's an upstream cause in a previous step
       // Passing Hudson Causes around makes @NonCPS viral in methods and such
       RunWrapper runWrapper = currentBuild.currentBuild as RunWrapper
       Cause causeType = runWrapper.getRawBuild().getCauses().last()
       Cause.UpstreamCause upstreamCause = causeType as Cause.UpstreamCause
       String upstreamProjectName = upstreamCause.upstreamProject
       copyArtifact(currentBuild, upstreamProjectName)
       }
      
       @NonCPS
       static void copyArtifact(CpsScript currentBuild, String upstreamProjectName) {
       currentBuild.copyArtifacts(
       projectName: upstreamProjectName,
       filter: "" +
       "**/${DemoConstant.DOCKER_IMAGE_FILENAME}, " +
       "**/${DemoConstant.CONAN_LOCKFILE_FILENAME}, " +
       "**/${DemoConstant.CONAN_BUILDORDER_FILENAME}",
       target: 'upstream',
       selector: currentBuild.upstream()
       )
       }
      }
      

            Unassigned Unassigned
            solvingj jerry wiltse
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: