Access shared artifact from a script

I need to download artifacts from other plans to my build plan. However, I need it to be more flexible than I can make it with the artifact download task. More specifically I need:

  1. Possible to get artifact from a specific branch, not necessary with the same name as the branch of the current plan.
  2. Possible to get artifact from a specific build, not only the latest successful build.

Can I do this from a script? The agent runs on Windows.

1 answer

1 accepted

I'd use the web side of things /browse/PLAN-KEY-38/artifact/shared/


/artifact/PLAN-KEY/shared/build-38/ is working better for me.

Adding example powershell script:

function DownloadFolderContents($url, $baseFolder = "./")
    if (!(Test-Path $baseFolder))
        New-Item $baseFolder -ItemType Directory > $null
    $basePath = Resolve-Path $baseFolder
    $html = (new-object System.Net.WebClient).DownloadString($url) -split "\n"
    $html |% `
        if ($_ -notmatch "<td><img .* alt=`"\((dir|file)\)`".*<a href=`"((?!`").*)`">(.*)</a>")
        { return }
        $type = $Matches[1]
        $path = $Matches[2]
        $name = $Matches[3]
        if ($type -eq "file")
        { (new-object System.Net.WebClient).DownloadFile("$bambooHost$path", $(Join-Path $basePath $name)) }
        { DownloadFolderContents -url "$bambooHost$path" -baseFolder $(Join-Path $baseFolder $name)}

$bambooHost = "http://YourOwnBambooHost"
$targetPlanKey = "PLAN-KEY"
$targetBuildNumber = "38"
$artifactName = "ArtifactName"

$url = "$bambooHost/artifact/$targetPlanKey/shared/build-$targetBuildNumber/$artifactName"


Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Renan Battaglin
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,321 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you