How to save a build log as an artifact

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Purpose

At times, you may want to save the logs from a Bamboo build as an artifact. Bamboo doesn't do this automatically, so this article describes a way to achieve this.

Solution

To download the build log, you can add a Script task with a curl command, which will download it.

  1. From your Plan configuration, take note of the Build key(s) you want to save the build log output. The format is <PROJECT-PLAN-JOB>
  2. Create a new Stage at the end of your Build – this will ensure that you capture as much of the previous job as you can

  3. If you want this to run regardless of the state of other Stages, make sure to select the Final Stage checkbox

  4. Add a Script task to your new Stage, containing the following command:

    # _build_key is the Job you want to have its output saved
    _build_key="PROJ-PLAN-JOB"
    _output_file="build-log.txt"
    _credentials="admin:admin"
    _bamboo_url="https://bamboo.mydomain.net"
    curl -s -k -u${_credentials} ${_bamboo_url}/download/${_build_key}/build_logs/${_build_key}-${bamboo.buildNumber}.log > ${_output_file}
  5. Add an Artifact definition for <build-log.txt> to the Job


Last modified on Sep 20, 2022

Was this helpful?

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