Copy artifacts from an upstream multi-branch pipeline

Raphael

I have the following Jenkins setup:

  1. A multi-branch pipeline which sometimes (on certain tag builds) triggers
  2. a pipeline that builds an installer from the upstream artifacts.

In the upstream MB-pipeline, I have the following fragments:

options {
    copyArtifactPermission('my-downstream-project');
}

post {
   success {
       script {
           if (isRelease()) {
               build job: 'my-downstream-project'
           }
       }
   }
}

The downstream pipeline, I then try to grab the artifacts:

copyArtifacts projectName: 'my-upstream-project', 
              selector: upstream(),
              filter: '*.jar',
              fingerprintArtifacts: true

While the downstream build is started, it fails with:

ERROR: Unable to find project for artifact copy: hds-access-code-cache This may be due to incorrect project name or permission settings; see help for project name in job configuration.

My understanding so far:

  • While I can't configure the Copy Artifact permission via the configuration UI for the MB-pipeline, the option is accepted and should work.
  • The examples I can find would use projectName: 'my-upstream-project/tag-name' as that's the actual job. I don't have a fixed branch or tag, though.

How can I correctly access the upstream artifact?

Raphael

It is possible to pass down the job name as parameter.

Change the upstream pipeline to:

build job: 'my-downstream-project',
      parameters: [string(name: 'upstreamJobName', value: env.BRANCH_NAME)]

Add the parameter to the downstream pipeline:

parameters { 
    string(name: 'upstreamJobName', 
        defaultValue: '', 
        description: 'The name of the job the triggering upstream build'
    )
}

And change the copy directive to:

copyArtifacts projectName: "my-upstream-project/${params.upstreamJobName}", 
              selector: upstream(),
              filter: '*.jar',
              fingerprintArtifacts: true

Et voila:

Copied 1 artifact from "My Upstream Project » my-tag" build number 1

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to copy artifacts from upstream project in Jenkins?

Jenkins: Trigger Multi-branch pipeline on upstream change

Jenkins : Copy artifacts from Multibranch pipeline

How to Copy Artifacts from other Jenkins Job from a Pipeline?

How can I copy artifacts from executed jobs with declarative pipeline?

Unable to copy artifacts from one stage to another stage in azure pipeline

Grant copy artIfact permission in multi-branch pipeline

Discard branch in forked repo and make a copy of same branch from upstream into fork

Trigger gitlab downstream pipeline from a upstream pipeline in a multi-project using trigger, rules and custom configuration variables

Jenkins Multi-Branch Pipeline Not Pruning Branches Deleted from Remote

Pipeline to use artifacts from 2 projects associated by the same git branch name

S3 Copy artifacts with Jenkins pipeline

How to parameterize selector for copy artifacts in Jenkins pipeline

Calling a job in a Multi Branch pipeline

Multi branch Pipeline in Azure Devops

delete erroneous branch remotes/upstream/upstream/develop from git[hub]

Failed to create a new branch from upstream

How to pull a certain branch from a upstream repository

Azure Devops Artifacts: disable saving packages from upstream sources

Get data from upstream job in Jenkins pipeline?

Upload Build artifacts from Jenkins Pipeline to Sharepoint

In Git, how do I separate a branch from its upstream branch?

"Build Periodically" with a Multi-branch Pipeline in Jenkins

Jenkins pipeline multi trigger options on Git branch

Discard old build in multi-branch pipeline job, doesn't really delete builds from server

How to copy the artifacts from slave to Jenkins workspace?

Copy artifacts from specific promoted build

Copy build artifacts to a source set in Gradle multi project build

github in Eclipse - not able to push a branch upstream from local

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    pump.io port in URL

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  14. 14

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  15. 15

    How to use merge windows unallocated space into Ubuntu using GParted?

  16. 16

    flutter: dropdown item programmatically unselect problem

  17. 17

    Pandas - check if dataframe has negative value in any column

  18. 18

    Nuget add packages gives access denied errors

  19. 19

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  20. 20

    Generate random UUIDv4 with Elm

  21. 21

    Client secret not provided in request error with Keycloak

HotTag

Archive