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

Copy artifact fails on first pipeline run with buildParameter selector

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Fixed but Unreleased (View Workflow)
    • Priority: Major
    • Resolution: Won't Fix
    • Labels:
      None
    • Environment:
      Jenkins 2.150.2
      Copy Artifact 1.41
      Pipeline 1.11.1 (also tested with 1.10.2)
    • Similar Issues:

      Description

      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

      ---------

        Attachments

          Activity

          rdesmond Ryan Desmond created issue -
          rdesmond Ryan Desmond made changes -
          Field Original Value New Value
          Description 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 do the right thing (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

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

          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"/>}
          [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
          ---------
          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 do the right thing (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

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

          {{The copy project pipeline:}}
          {code:java}
          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')
          }{code}
           

           

          Return from the first build (that fails, started with Build):
          {code:java}
          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{code}

           
          Return from the second build (that works, started with Build With Parameters and defaults):
          {code:java}
          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{code}

          ---------
          rdesmond Ryan Desmond made changes -
          Description 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 do the right thing (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

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

          {{The copy project pipeline:}}
          {code:java}
          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')
          }{code}
           

           

          Return from the first build (that fails, started with Build):
          {code:java}
          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{code}

           
          Return from the second build (that works, started with Build With Parameters and defaults):
          {code:java}
          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{code}

          ---------
          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 do the right thing (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

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

           

          {{The copy project pipeline:}}
          {code:java}
          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')
          }{code}
            

          Return from the first build (that fails, started with Build):
          {code:java}
          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{code}
           

          Return from the second build (that works, started with Build With Parameters and defaults):
          {code:java}
          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{code}
          ---------
          rdesmond Ryan Desmond made changes -
          Description 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 do the right thing (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

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

           

          {{The copy project pipeline:}}
          {code:java}
          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')
          }{code}
            

          Return from the first build (that fails, started with Build):
          {code:java}
          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{code}
           

          Return from the second build (that works, started with Build With Parameters and defaults):
          {code:java}
          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{code}
          ---------
          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:}}
          {code:java}
          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')
          }{code}
            

          Return from the first build (that fails, started with Build):
          {code:java}
          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{code}
           

          Return from the second build (that works, started with Build With Parameters and defaults):
          {code:java}
          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{code}
          ---------
          ikedam ikedam made changes -
          Status Open [ 1 ] Fixed but Unreleased [ 10203 ]
          Assignee Ryan Desmond [ rdesmond ]
          Resolution Won't Fix [ 2 ]

            People

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

              Dates

              • Created:
                Updated:
                Resolved: