How to save a build log as an artifact
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.
- 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>
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
If you want this to run regardless of the state of other Stages, make sure to select the Final Stage checkbox
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}
Add an Artifact definition for
<build-log.txt>
to the Job