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

Copy artifacts from multi-branch pipeline project with project name as a build parameter fails with "Unable to find project for artifact copy"

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: copyartifact-plugin
    • Labels:
      None
    • Environment:
      Master & slave: Debian Jessie 64 bit, Oracle JRE, installed from deb repo
      Jenkins: 2.19.3
      CopyArtifactPlugin: 1.38.1
    • Similar Issues:

      Description

      We have a multi-branch pipeline project that produces artifacts, we also have a freeform project that is configured with build parameters to copy artifacts from the pipeline job based on the parameters supplied.

      When I set the project name parameter to something like

      myproject/${BRANCH_NAME} 

      the job fails with

      Unable to find project for artifact copy: myproject/mybranch

      If it set the project name parameter to

      myproject/mybranch

      it works fine.

      We aren't using matrix permissions, logged in users can do anything and Allow anonymous read access is checked. I tried setting the project property CopyArtifactPermissionProperty in the JenkinsFile to

      properties([[$class: 'CopyArtifactPermissionProperty', projectNames: '*']])
      

      but this made no difference.

        Attachments

          Activity

          Hide
          lessless Yevhenii Kurtov added a comment -

          Getting same error in multibranch enviornment with
          `step([$class: 'CopyArtifact', fingerprintArtifacts: true, optional: true, projectName: projectName, selector: [$class: 'StatusBuildSelector', stable: false]])` where projectName is a multibranch job name

          Show
          lessless Yevhenii Kurtov added a comment - Getting same error in multibranch enviornment with `step([$class: 'CopyArtifact', fingerprintArtifacts: true, optional: true, projectName: projectName, selector: [$class: 'StatusBuildSelector', stable: false] ])` where projectName is a multibranch job name
          Hide
          lukepeterson Luke Peterson added a comment -

          Make sure you're using double quotes in the parameter that contains the branchName.  For example: projectName: "my-project-name/${env.BRANCH_NAME}" as opposed to projectName: 'my-project-name/${env.BRANCH_NAME}'.

          Show
          lukepeterson Luke Peterson added a comment - Make sure you're using double quotes in the parameter that contains the branchName.  For example: projectName: "my-project-name/${env.BRANCH_NAME}" as opposed to projectName: 'my-project-name/${env.BRANCH_NAME}'.
          Hide
          matty666 Matt Evans added a comment -

          Luke Peterson The copy artifacts project name doesn't have any quotes around it. This is in the config for a freeform project that copies the artifacts from a multi-branch pipeline project. I tried putting double quotes around the project name property value but that didn't work

          Show
          matty666 Matt Evans added a comment - Luke Peterson The copy artifacts project name doesn't have any quotes around it. This is in the config for a freeform project that copies the artifacts from a multi-branch pipeline project. I tried putting double quotes around the project name property value but that didn't work
          Hide
          nelissen_peter peter nelissen added a comment -

          Any workaround for this issue?

          Show
          nelissen_peter peter nelissen added a comment - Any workaround for this issue?
          Hide
          haggai_e Haggai Eran added a comment -

          Not sure if this is the same issue, but I just spent a couple of days debugging a similar error message when trying to copy artifact from one multibranch pipeline into another. Eventually the problem was that one of the branches in the source job had the same name as the destination job. E.g. copying from job "a/master" to job "b/a" failed because if I understand correctly the plugin was looking for an item named "b/a/master". I solved the issue by using a full path instead (e.g. "/a/master").

          Show
          haggai_e Haggai Eran added a comment - Not sure if this is the same issue, but I just spent a couple of days debugging a similar error message when trying to copy artifact from one multibranch pipeline into another. Eventually the problem was that one of the branches in the source job had the same name as the destination job. E.g. copying from job "a/master" to job "b/a" failed because if I understand correctly the plugin was looking for an item named "b/a/master". I solved the issue by using a full path instead (e.g. "/a/master").
          Hide
          apikas Anders Pikas added a comment -

          Thanks, Haggai Eran! I solved this in 30 minutes thanks to you, not a couple of days. I had the same problem as you: the pipeline I was copying from started with "core/" and the pipeline I was running had a name ending in "/core".

          I always specify absolute job/project/pipeline paths as absolute, BUT Jenkins itself gives ${env.JOB_NAME} as a relative path for some reason (maybe backward compatibility?).

          env.JOB_NAME.replaceFirst('^(?!/)', '/')
          
          Show
          apikas Anders Pikas added a comment - Thanks, Haggai Eran ! I solved this in 30 minutes thanks to you, not a couple of days. I had the same problem as you: the pipeline I was copying from started with "core/" and the pipeline I was running had a name ending in "/core". I always specify absolute job/project/pipeline paths as absolute, BUT Jenkins itself gives ${env.JOB_NAME} as a relative path for some reason (maybe backward compatibility?). env.JOB_NAME.replaceFirst( '^(?!/)' , '/' )

            People

            • Assignee:
              Unassigned
              Reporter:
              matty666 Matt Evans
            • Votes:
              9 Vote for this issue
              Watchers:
              20 Start watching this issue

              Dates

              • Created:
                Updated: