You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将Bamboo构建日志压缩为工件供远程用户快速下载?

Compressing Bamboo Build Logs as Artifacts for Faster Downloads

Got it, let's sort this out for your team in India—compressing those build logs into artifacts will absolutely slash their download wait times. Here are two straightforward, reliable ways to set this up in Bamboo:

Method 1: Combine a Script Task + Archive Artifacts Task

This is the most flexible approach, especially if you want clear separation between compression and archiving steps.

  1. Add a Script Task to your build stage (place it after your main build tasks, right before you archive artifacts):

    • For Linux/macOS agents, use this bash script to compress all logs into a single tar.gz file:
      # Compress the entire build log directory into a compressed archive
      tar -czf ${bamboo.build.working.directory}/build-logs.tar.gz -C ${bamboo.build.log.dir} .
      
    • For Windows agents, use this PowerShell script to create a zip file:
      # Compress all log files into a zip archive (overwrite if it exists)
      Compress-Archive -Path "${bamboo.build.log.dir}\*" -DestinationPath "${bamboo.build.working.directory}\build-logs.zip" -Force
      

    Note: We use ${bamboo.build.log.dir} (Bamboo's built-in variable) to target the exact log directory, so this works no matter where your agent is running.

  2. Add an Archive Artifacts Task right after the script task:

    • In the "Artifacts to archive" field, enter the path to your compressed file: build-logs.tar.gz (or build-logs.zip for Windows).
    • You can also set a friendly name like "Compressed Build Logs" so your team knows exactly what they're downloading.

Method 2: Use a Post-build Script to Handle Everything in One Step

If you prefer fewer tasks, you can handle compression and artifact registration in a single post-build script:

  1. Go to your build plan's Post-build Actions and add a Run script action.
  2. Use the appropriate script for your agent OS:
    • Linux/macOS:
      # Compress logs and create a file listing the artifact for Bamboo to pick up
      tar -czf ${bamboo.build.working.directory}/build-logs.tar.gz -C ${bamboo.build.log.dir} .
      echo "build-logs.tar.gz" >> ${bamboo.build.working.directory}/artifacts.txt
      
    • Windows:
      Compress-Archive -Path "${bamboo.build.log.dir}\*" -DestinationPath "${bamboo.build.working.directory}\build-logs.zip" -Force
      Add-Content -Path "${bamboo.build.working.directory}\artifacts.txt" -Value "build-logs.zip"
      
  3. Add an Archive Artifacts Task and set "Artifacts to archive" to @artifacts.txt—Bamboo will read this file to know which compressed log to store as an artifact.

Pro Tips for Optimal Results

  • Choose the right compression format: tar.xz has a higher compression ratio than tar.gz (smaller file size) but takes a bit longer to compress/decompress. If download speed is your top priority, it's worth the tradeoff.
  • Verify permissions: Make sure your Bamboo agent has read access to ${bamboo.build.log.dir} and write access to ${bamboo.build.working.directory} (this is usually enabled by default, but it's good to double-check if you run into errors).
  • Test with a small build: Run a test build first to confirm the compressed artifact is generated correctly and that your team can download and extract it without issues.

内容的提问来源于stack exchange,提问作者Jason Templeman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:13:04