Bamboo Best Practice - Sharing artifacts

General overview


We've already had a look at techniques such as fail fast and artifact promotion as ways of improving your Bamboo processes in the using stages Best Practice guide, but here we're going to dig a little deeper and look at some ways that you can get artifact sharing to work for you.

Best practice approaches

Sharing build artifacts with downstream processes

See Artifact promotion for a description of this technique.

How do I configure artifact sharing between jobs?

In Bamboo, artifact sharing between jobs is configured using the Artifacts tab on the plan's configuration. Find the artifact you want to share, select Edit, and select the Shared checkbox.

Edit artifact definition window

Check out Sharing artifacts between jobs to learn how to configure your Bamboo server to take advantage of artifact sharing between jobs.



Sharing artifacts between plans

Objective

Identify and describe how artifact sharing between plans can be achieved.

Learning outcomes

After completing this section, you will understand how to share an artifact between plans.

Overview

We discussed above how we can achieve significant time benefits from capturing and sharing artifacts to downstream processes rather than checking out and compiling each time the artifact is required. Generating an artifact at the top of the development pipelie, and passing it to successive downstream processes also has the benefit of ensuring the integrity of the code is maintained throughout the pipeline, because we know it is the exact same code that we tested earlier on. We also discussed how we can manage passing artifacts within a build plan, but let's suppose that we want to pass artifacts between two plans. Easy: we use the download artifact task to make the artifact available from one plan to another.

Example scenario

Let's consider the following artifact sharing example:

Imagine that we have a build plan that creates and uses an artifact - Artifact A. Now let's suppose that we also have a child plan, and we would like to use Artifact A in this plan for some other purpose. Bamboo doesn't technically allow you to share artifacts between plans (but watch this space), so we can use a work around to get our artifact shared into the child plan. We copy it from the parent plan to a remote storage location, then use the artifact download task to obtain it for the new plan. Note: this approach differs significantly to the process for sharing artifacts between jobs. 

Parent plan

Step 1: Checkout & compile - We need to check out the relevant code from the repository and compile it into an artifact. Our artifact is now defined and available for use by downstream jobs. Let's give it a name - Artifact A - and specify its location, so downstream jobs can find it, though of course only jobs in downstream stages can consume it.

Step 2: Testing - We can use some fail fast methodology and run some tests on our artifact before we go any further. We can conduct short and rapid unit tests and longer functional testing on our artifact. But we already know that artifact sharing can be used to increase testing speed in both cases.

Step 3: Deployment - When testing is complete, the artifact can be deployed to a QA environment by a consuming job that runs a deployment script against it, but we still need to share it with the child plan.

Step 4: Copy artifact out - The final step of this plan is to use a task to copy the artifact out to a remote location such as Nexus or Artifactory, using the applicable Bamboo plugin. Alternatively, simply run a script task to copy the artifact to a remote file server location on your own network.


Child plan

Step 1: Copy artifact in - The first step of the child plan is to use a task to copy the artifact in from where the parent plan left it. Depending on the method you used to copy it out, you may require a task that utilizes a Bamboo plugin.

Step 2: Business as usual - Now that we have copied the artifact in, we can perform regular Bamboo operations as part of an ongoing build plan. These could be additional tests, or deployments into different environments.

Extending artifact sharing

And of course, once we have our artifact neatly stored in remote storage, the artifact download task means that it can associated with any build plans that we may want to run.

Conclusion

Artifact sharing is a powerful technique for making single artifacts available. Artifact sharing across plans allows us to make artifacts available for different build plans from one checkout and compile. We know that we will always be using a consistent artifact which reduces the time overhead of multiple checkout and compile steps.

How do I configure artifact sharing between jobs?

Artifact sharing between jobs is configured using the Artifact download task:

Artifact download task configuration

Check out Sharing artifacts between build plans to learn how to configure your Bamboo server to take advantage of artifact sharing between plans.

Last modified on Jul 26, 2021

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.