Skip to end of metadata
Go to start of metadata

This page describes how to share artifacts. Bamboo allows artifact sharing between:

  • Jobs
  • Build plans
  • Build plans to deployment environments.

 

Sharing artifacts between jobs

You can share artifacts between jobs in different stages using artifact dependencies. For example, you may want to run acceptance tests on a build, sharing the same WAR from one job to another without rebuilding it each time.

Each time the artifact is shared with a subsequent job, it is copied to the job's agent.

To share an artifact between two jobs in different stages:

  1. Navigate to the configuration pages for the job that will produce the artifact, as described on Configuring jobs, and click the Artifacts tab (see Configuring a job's build artifacts).
  2. Click Edit for the artifact that you want to share. The artifact definition will be displayed.
  3. Select the Shared check box and then click Save.
  4. Navigate to the job in a subsequent stage that will consume the artifact, and click the Artifacts tab. Click Create Dependency. Complete the fields on the screen (see screenshot below) and click Create.

On this page:

  1. The Artifact list only shows artifacts from jobs in previous stages that have been marked as shared. This is described in Configuring a job's build artifacts.
  2. Destination directory is relative to the build directory. Do not use the absolute path to refer to the destination directory.

Screenshot: Creating an artifact dependency

Sharing artifacts between build plans

You can share artifacts between different build plans, however you need to use the 'Artifact downloader task' to do so. For example, you may want to run acceptance tests on a particular build from a different plan by sharing the same WAR from one plan to another without rebuilding it each time.

To share an artifact between two build plans:

  1. Locate the build plan that you wish to associate an artifact with. 
    1. Select Configure plan from the 'Actions' drop down menu. The plan configuration window will display
    2. Click on Stages & jobs and select a job or create a new job if one does not already exist 
    3. Click on the Tasks tab for the selected job. The 'Tasks' pane will appear
  2. Click the Add task button. The 'Task types' window will appear. Select Artifact Downloader Task to open the 'Artifact downloader task' configuration pane:

     
    Complete the configuration using the following options:

    FieldDescriptionOptional?
    Task descriptionA brief description of the artifact downloader task(tick)
    Disable this taskCheck this box to disable the task-
    Source PlanThe build plan that is the source of the artifact you need to download(error)
  3. Click on Add another artifact to add another artifact to the download list. Alternatively, use the grey cross icon to delete an artifact from your configuration
  4. Click on Save to save your artifact download configuration.
  1. The Artifact drop down menu only shows artifacts from jobs in previous stages that have been marked as shared. This is described in  Configuring a job's build artifacts
  2. Destination directory is relative to the build directory. Do not use the absolute path to refer to the destination directory.
  3. The artifact from the most recent successful build will be used. If there are no successful builds from the artifact-producing plan or the artifacts have expired, the artifact-consuming job will fail.

Sharing artifacts from a build plan to a deployment environment

You can also share artifacts from a build plan into a deployment environment. For example, you may wish to share a particular build result from a plan with a deployment environment. To do this, you need to add the 'Artifact downloader task' to a deployment environment during or after the environment creation process. 

To share an artifact from a build plan to a deployment environment:

  1. Open your deployment project and expand the relevant environment panel. In the Other settings section, click on the Tasks button. The 'Set up tasks' screen will display:


  2. Click Add task. The 'Task type' selection window will display. Select Artifact Downloader Task to open the 'Artifact downloader task configuration' pane:


     
    Complete the configuration using the following options:

    FieldDescriptionOptional?
    Task descriptionA brief description of the artifact downloader task(tick)
    Disable this taskCheck this box to disable the task-
    Artifact NameUse the drop down menu to locate the name of the artifact that you want to download(error)
    Destination PathThe location of the working directory into which you want the artifact downloaded(tick)
  3. Click Add another artifact to add another artifact to the download list. 
  4. Click Save to save your artifact download configuration.

 

  1. The Artifact drop down menu only shows artifacts from jobs in previous stages that have been marked as shared. This is described in  Configuring a job's build artifacts
  2. Destination directory is relative to the build directory. Do not use the absolute path to refer to the destination directory.
  • No labels

20 Comments

  1. Anonymous

    So when sharing artifacts between plans thru the Artifact Download task, does bamboo ensure that the artifact that's downloaded to the destination build comes from the last successful build of the origin plan.

  2. Yes, that's right, it's taken from the latest successful build, or if it was triggered by a dependent build, then it will use artifacts from that dependency chain.

    1. Hi Nathan, I have a plan that is a child to multiple plans. I want to download the artifacts from the parent plan that initiated the build. You say that if a build is triggered as a dependent, then it will use artifacts from the dependency chain. However, in the artifact download task I must select a specific source plan to get the artifacts from. Am I missing something?

  3. My question is if there is a bamboo variable available for the artifact name once its been downloaded in a deployment plan? We build war name from a series of variables, one of which is not available to the deployment plan (specifically the repo revision). We want to use this artifact in a command task but since we are not sure of the name we cannot.

    1. Hi Lloyd,
      Unfortunastely there isn't a variable for the artifact name. However, there are variables for the repository revision that can be used from the deployment plan (bamboo.repository.revision.number). As a rule of thumb, any plan level variable should be available to the deployment project.

      See the Bamboo variables reference for more details.

      Thanks
      James 

      1. Thanks James

        I've found that its actually available as bamboo.planRepository.revision in a deployment plan.

      2. Anonymous

        Boo. This would be very useful. Please add.

        1. Is there a formal request for this feature?

  4. Anonymous

    Is it possible to dowlnoad shared artifacts from several build plans to a deployment environment? In build plans I can simply crate many "Artifact download" tasks and set them to different build plans. In deployment case, I have only one build plan, that's not very convenient.

  5. Anonymous

    +1 for the need for having artifact names as variables.  I download two artifacts (nuget packages) into a deployment step, but I don't know what the files will be called.  I need to pass these into scripts as variable names.  Currently I have to download one of them, rename *.nupkg to a name I know, then perform my operations.  I then delete *.nupkg and repeat for the 2nd artifact.

  6. Anonymous

    Is it possible to duplicate an environment?  I have a series of steps that I've set up for the Test environment, which I want to duplicate for Staging.  It looks like I have to set up all the tasks and variables again.  Am I missing something?

    1. Hi,

      This functionality is in the pipeline for future development: BAM-14066

      Vote for this issue to increase it's chances of a speedy resolution.

      Cheers,

      Nathan

  7. Is it possible to set up an optionally artifact download? I have two plans that feed into a job and sometimes a branch only exists on one plan. I keep getting the error, "(java.lang.IllegalArgumentException : Unable to find at least one successful result for plan: GFOLRP-SCR3)". If I could set the artifact download to optionally get the artifact if it exists, then it would fix my issue. 

    1. Hi Christopher,

      Can you raise a support ticket with us at https://support.atlassian.com ? We will need to investigate this further

  8. How do I include the entire scm clone as an artifact?

    I tried the following pattern match:

    But that causes the bamboo java instance to consume 100% cpu and the web interface to become unresponsive.

    1. I came across the same question today. As I was reading the best practice documentation about stages, I tried to put compilation, testing and deployment artifact creation into separate stages - now of course I would like to share the copmlete working directory between compile and test, as both stages are using Maven to be executed. I could, however, reduce the artifact exchange between test and "deployment artifact creation" to the content of all target directories only.

      The alternative approach is to do everything in one single stage - I will probably go back to that setup. There are some posts around that talk about artifact sharing but I'm not convinced that this is the right way to go, see https://answers.atlassian.com/questions/33651/stages-and-artifact-passing

       

      1. The artifact stuff seems to choke if there's too much data passed between stages.

        I ended up having to copy the workspace to /tmp at the end of each stage.

        And then pick it up at the start of the next stage.

        Something like this for the end of the first stage:

        Then at at start of the 2nd stage:

        Seems to work ok so far.

  9. I would like to pull an artifact from the same plan, but from a previous build. Is that possible?

  10. How can I use shared artifact from a specific branch?
    "Download artifact" task let me choose the Plan, but what if this plan have more then one branch? from which branch the artifact will be taken?

    Thanks 

  11. would it be possible to download an artifact from another plan independently if the plan has been successful or not?