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

This widget could not be displayed.

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
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

199 views 1 3
Join discussion

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