-
Bug
-
Resolution: Unresolved
-
Minor
-
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() ) } }