How to save a build log as an artifact

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

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.

*Fisheye および Crucible は除く

目的

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.

ソリューション

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


最終更新日 2022 年 9 月 20 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.