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

Copy artifacts from upstream: Unable to find project for artifact copy

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • copyartifact-plugin
    • None

      I have a multi-branch pipeline that should be triggered by another multi-branch pipeline. The trigger is configured at the end of the Jenkinsfile as follows:
      {{  }}
      properties([
        pipelineTriggers([upstream({{upstreamProjects: "myproject/$

      {branchName}

      "}})]),
        disableConcurrentBuilds()
      ])

      update: the code above is being modified by this editor all the time... never mind those extra brackets etc. I didn't add them. See screenshot.

      branchname is defined at the top of the file, as follows:
      def branchName = "${BRANCH_NAME}".replace("/", "%2F")

      To copy the artifacts I use:
      step([$class: 'CopyArtifact', target: 'input/upstream', selector: [$class: 'TriggeredBuildSelector']])

      The pipeline is triggered, but the copy artifact step fails with this error:

      hudson.AbortException: Unable to find project for artifact copy: null This may be due to incorrect project name or permission settings; see help for project name in job configuration.

      I tried to add the permissions property in the upstream pipeline, as follows:
      properties([[$class: 'CopyArtifactPermissionProperty', projectNames: '*']])
       
      But I get the same error. The expected behavior is of course to copy the artifacts from the upstream pipeline... if I'm doing something wrong then please let me know what it is so I can fix my pipeline.Thank you.

          [JENKINS-48339] Copy artifacts from upstream: Unable to find project for artifact copy

          Cedric H added a comment -

          Using Copy Artifact Plugin Version 705.v5295cffec284, I have a multi-branch project PR build calling a build (a branch from another multi-branch project) and trying to copy an artifact from the downstream job locally.

          Nonetheless, the outcome is always:

          Unable to find project for artifact copy: /downstream-project/some-branch
          This may be due to incorrect project name or permission settings; see help for project name in job configuration.
          

           

          In the first multi-branch project, the PR branch pipeline has a stage as:

              stage('Call other build') {
                steps {
                  script {
          		
          			def otherJobName = 'downstream-project/some-branch'
          			def jobBuildResult = build job:"/${otherJobName}", parameters : [ 
          					<some parameters with values>
                          ], wait: true
          			
          			echo "downstream job #: ${jobBuildResult.number}"
          			
          			copyArtifacts(projectName: "/${otherJobName}", selector: specific("${jobBuildResult.number}"), filter: 'some-file.conf', target: 'my-dir');
                  }
                }
              }
          

          The downstream multi-branch project branch pipeline has the following options set:

            options {
                copyArtifactPermission('upstream-project,upstream-project/*');
            }
          

          Are there special configurations to be done for copyArtifacts to work in such case?

          Cedric H added a comment - Using Copy Artifact Plugin Version 705.v5295cffec284 , I have a multi-branch project PR build calling a build (a branch from another multi-branch project) and trying to copy an artifact from the downstream job locally. Nonetheless, the outcome is always: Unable to find project for artifact copy: /downstream-project/some-branch This may be due to incorrect project name or permission settings; see help for project name in job configuration.   In the first multi-branch project, the PR branch pipeline has a stage as: stage( 'Call other build' ) { steps { script { def otherJobName = 'downstream-project/some-branch' def jobBuildResult = build job: "/${otherJobName}" , parameters : [ <some parameters with values> ], wait: true echo "downstream job #: ${jobBuildResult.number}" copyArtifacts(projectName: "/${otherJobName}" , selector: specific( "${jobBuildResult.number}" ), filter: 'some-file.conf' , target: 'my-dir' ); } } } The downstream multi-branch project branch pipeline has the following options set: options { copyArtifactPermission( 'upstream-project,upstream-project/*' ); } Are there special configurations to be done for copyArtifacts to work in such case?

          Zaitcev Peter added a comment -

          It looks like "TriggerBuildSelector" does the exact opposite – it chooses NOT the upstream build, but the downstream one.

          Zaitcev Peter added a comment - It looks like "TriggerBuildSelector" does the exact opposite – it chooses NOT the upstream build, but the downstream one.

            Unassigned Unassigned
            pbro Paolo Brocco
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: