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

Copy artifact fails on first pipeline run with buildParameter selector

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • None
    • Jenkins 2.150.2
      Copy Artifact 1.41
      Pipeline 1.11.1 (also tested with 1.10.2)

      We have a job which uses a multibranch pipeline and copies from another job, based on a parameter. In the pipeline, it is expected that the default parameter (which is lastSuccessfulBuild) will be used (the parameter is for cases that the Jenkinsfile is used elsewhere).

      When the branch is newly created, the copy fails with ERROR: Unable to find a build for artifact copy from: UPSTREAM_PROJECT.  (This same error occurs when the parameters are manually removed and the job is rerun.)

      The defaults are used to set params, which was fixed in JENKINS-35698, but they don't appear to be used for copy artifact.

       

      In a test case, a job UPSTREAM_PROJECT  was created with a single artifact.  A scripted pipeline build was created to pull from that job and print the parameters.  It uses a properties block to create the parameter and  perform the copy.  On the first run, it falls and on subsequent runs it succeeds.

      The copy project pipeline:

      properties([
        parameters([
          [$class: 'BuildSelectorParameter', defaultSelector: lastSuccessful(), description: 'Upstream project', name: 'UPSTREAM'],
        ])
      ])
      node {
        print params
        print buildParameter('UPSTREAM')
        copyArtifacts fingerprintArtifacts: false, flatten: true, projectName: 'UPSTREAM_PROJECT', selector: buildParameter('UPSTREAM')
      }

        

      Return from the first build (that fails, started with Build):

      Started by user MY_USER
      Running in Durability level: MAX_SURVIVABILITY
      [Pipeline] Start of Pipeline
      [Pipeline] properties
      [Pipeline] node
      Running on Ubuntu 16.04 (i-09db975617c73099c) in /home/ubuntu/workspace/Test
      [Pipeline] {
      [Pipeline] echo
      {UPSTREAM=<StatusBuildSelector plugin="copyartifact@1.41"/>}
      [Pipeline] echo
      @buildParameter(<anonymous>=UPSTREAM)
      [Pipeline] copyArtifacts
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      ERROR: Unable to find a build for artifact copy from: UPSTREAM_PROJECT
      Finished: FAILURE

       

      Return from the second build (that works, started with Build With Parameters and defaults):

      Started by user MY_USER
      Running in Durability level: MAX_SURVIVABILITY
      [Pipeline] Start of Pipeline
      [Pipeline] properties
      [Pipeline] node
      Running on Ubuntu 16.04 (i-09db975617c73099c) in /home/ubuntu/workspace/Test
      [Pipeline] {
      [Pipeline] echo
      {UPSTREAM=<StatusBuildSelector plugin="copyartifact@1.41"/>, BUILD_TYPE=Release, STRING=string, BOOLEAN=true}
      [Pipeline] echo
      @buildParameter(<anonymous>=UPSTREAM)
      [Pipeline] copyArtifacts
      Copied 1 artifact from "UPSTREAM_PROJECT" build number 2
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      Finished: SUCCESS

      ---------

            rdesmond Ryan Desmond
            rdesmond Ryan Desmond
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: