Index
Downloads (PDF, HTML & XML formats)
[Bamboo Knowledge Base Home]
Documentation for Bamboo 4.0.x. Documentation for earlier versions of Bamboo is available too.
This page describes 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, sharing the same WAR from one job to another without rebuilding it each time.
This page also describes 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.
On this page:
You can share artifacts between jobs in different stages using 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:
Screenshot: Creating an artifact dependency
Before you begin:
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 the 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: Maven artifact sharing example
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:
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>
<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.Screenshot: Enabling Maven artifact sharing on the Miscellaneous tab for a plan
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).
7 Comments
Bob Swift
Mar 22, 2011Is there a difference between build artifacts and job artifacts as shown on the screen shot on Bamboo 3.0 Release Notes? If so, can you expand how to define a job artifact verses a build artifact? I was able to create a build artifact and share it between jobs but the artifact isn't needed once the build completes.
Jens Schumacher
Mar 30, 2011There is no difference between Build and Job artifacts. All artifacts are removed based on the build expiry settings within the global administration.
Kevin Loveland
Apr 28, 2011Where are the pom.xml changes required? Are they required in the root pom.xml? Are they required in each of the sub-module pom.xml? Are they only required in the modules pom.xml you wish to share?
What exactly do the changes to the pom.xml file do?
Are there other configuration options that can be provided?
dan carter
Dec 13, 2011I have enabled maven artifact sharing, and i have added the build plugin to my pom.xml, but they artifact tab says
Produced Maven Artifacts
No maven artifacts have been produced for this Job
Do I have to manually add an artifact definition for every artifact in my multimodule build? Shouldn't it work this out from my poms?
If i have to manually define (and maintain) the artefact definitions. Can i add just one artefact definition and use a pattern like */target/*.jar ?
Will be a pain if i have to maintain my project structure in both maven and bamboo.
dan carter
Dec 13, 2011"If a Job needs to deploy an artifact (i.e. produce the artifact), mark the artifact as shared in the relevant artifact definition."
Do i need to create the artifact definintion, or should the definition appear automatically once 'maven artifact sharing' is enabled.
If i need to create it manually, what should the definition look like? Should it point to the directory containing the maven project, or point to the target subdirectory containing the built jar, or point to the pom.xml file, or point to the jar, or ...?
Can I use pattern matching to select multiple projects / artefacts?
dan carter
Dec 13, 2011Also, does the maven build plugin "bamboo-artifact-sharing-maven-plugin" need adding to the pom that is producing the artifact or the one consuming the artifact?
Anonymous
May 17, 2012Hi there,
I have a plan composed of two jobs/stages. The first stage creates a directory "foo" with a bunch of files and exposes them as an artifact (the entire foo directory is a single artifact). It is set up as a shared artifact, with the destination directory set to "artifacts". In the second stage, there is a task that attempts to do some work with this artifact.
I am having trouble finding out where exactly Bamboo puts it. I have tried to access it in my second stage using this path:
${bamboo.build.working.directory}/artifacts/foo
The documentation implies it should be in a destination directory relative to the build dir, or am I misunderstanding?