The instructions on this page describe how to configure artifact sharing between Jobs in a Plan. Artifact sharing allows you to pass an artifact from one Job to a Job in a subsequent Stage. That is, the artifact is copied to the subsequent Job's agent. Note, you cannot pass artifacts between Jobs in the same stage. For example, you may want to run acceptance tests on a build, share the WAR from one Job to another without rebuilding it each time. The instructions on this page also describe how to configure artifact sharing when you are using a Maven builder. In this case, the artifact is deployed to and resolved from a Maven repository by Jobs, rather than being copied from agent to agent. |
Sharing Artifacts between Jobs
You can share artifacts between Jobs in different Stages via artifact dependencies. 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:
- Navigate to the Job that will produce the artifact, as described on Configuring a Job.
- Click the 'Artifacts' tab to display the Job's Artifacts settings (see Configuring a Job's Build Artifacts).
- Click the 'Edit' link for the artifact that you want to share. The artifact definition will be displayed.
- Tick the 'Shared' checkbox.
- Navigate to the Job in a subsequent Stage that will consume the artifact, and click the 'Artifacts' tab.
- Click the 'Create Dependency' button.
- Complete the fields on the screen (see screenshot below) and click 'Create'.
Please note:- The artifact dropdown only lists artifacts from Jobs in previous stages that have been marked as shared. This is described inĀ Configuring a Job's Build Artifacts.
- The destination directory is relative to the build directory. Do not use the absolute path to refer to the destination directory.
Screenshot above: Creating an Artifact Dependency
Sharing Artifacts between Maven Jobs (Beta)
Before you begin:
- Maven artifact sharing is currently in beta. We recommend that you do not use it with any critical production systems.
- Maven artifact sharing is not supported for Maven 1.
About Maven Artifact Sharing
Maven artifact sharing works by producing new remote repositories when you run a Plan. These are temporary equivalents of the deployment repositories configured within the project's pom.xml
files. For example, if the project deploys its repository to the 'mycorp-private' repository at http://repository.example.com/ then Bamboo will create a 'mycorp-private' repository for each Plan result hosted on the Bamboo server.
When a Job produces a Maven artifact, it is deployed to this repository. A subsequent Job that consumes an artifact created by this process will resolve it from the repository within Bamboo. This process of deploying and resolving artifacts can then be repeated, as necessary across subsequent Jobs in later Stages. Once a build has completed, the temporary repositories are removed to conserve disk space, unless specified otherwise (see configuration instructions below).
The diagram below shows an example of how artifact sharing works. Two Jobs, Job A
and Job B
, share an artifact in Plan, MyPlan
. Job A builds the artifact then deploys it to the temporary remote Maven repository. Job A triggers Job B. Job B resolves the artifact, builds, then deploys the artifact back to the repository.
Diagram above: Maven artifact sharing example
Configuring Maven Artifact Sharing
Artifact sharing is configured differently when using Maven 2 or 3 as a builder for your Jobs. Artifacts are deployed to and resolved from a Maven repository, rather than copied from agent to agent. You will need to change your pom.xml file, as well as configure the relevant Jobs to set up artifact sharing.
Before you begin:
- Your Bamboo URL must be specified correctly for Maven artifact sharing to work correctly. For example, do not use localhost as part of your Bamboo URL. For more information, see Specifying Bamboo's URL.
To share an artifact between two Maven Jobs in different Stages:
Edit your
pom.xml
file and add the following plugin definition:<build> <plugins> <plugin> <groupId>com.atlassian.bamboo.maven.sharing</groupId> <artifactId>bamboo-artifact-sharing-maven-plugin</artifactId> <version>3.0-i5</version> <executions> <execution> <id>sharing</id> <goals> <goal>share</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
- Note, the version number specified above (
<version>
) must match the version of Bamboo you are using. This version number number will be compatible across minor releases of Bamboo, unless specified otherwise in the relevant upgrade.
- Note, the version number specified above (
- Navigate to the Plan that you want to enable artifact sharing for, and click the 'Miscellaneous' tab (see screenshot below).
- Tick the 'Enabled' checkbox.
- If you don't want to keep the Maven artifact repositories generated for each build of the Plan, tick the 'Expire Maven Repository Artifacts' checkbox.
If you do not tick this checkbox, please note that each plan result may contain hundreds of megabytes of Maven artifacts. Ensure that you have sufficient disk space to accommodate this. - Configure artifact sharing between the desired Jobs, as described above. That is,
- If a Job needs to deploy an artifact (i.e. produce the artifact), mark the artifact as shared in the relevant artifact definition.
- If a Job needs to resolve an artifact (i.e. consume the artifact), create an artifact dependency for the artifact that it needs to resolve.
Screenshot above: Enabling Maven artifact sharing for a Plan
Screenshot above: Viewing the build result for a Job with Maven artifact sharing
Notes
Artifacts are copied to a subdirectory (
/JOB_KEY/download-data/
) under your 'Build Directory' folder (see Locating Important Directories and Files). Artifacts which you define in the plan are listed in each build result as artifacts (see Viewing a Build's Artifacts in the Bamboo User's Guide).
Related Topics
Viewing a Build's Artifacts
Configuring a Job's Build Artifacts
Attachments:








