How to find artifact path for Rest API(automate artifact downloads)

Completed

I've been trying this for a while. So far I am able to download specific build artifacts using: 
http://teamcity/guestAuth/repository/download/blah_blah_Main_InstallCreatorForMaster/74479:id/C.Installer_3.6.0-dev.350.exe

 

However I am trying to build an automation suite. I need to download last successful build and the build number increases(i.e. next build is dev.351)

I have seen/tried numerous ways to do this like:


http://teamcity:8111/app/rest/builds/buildType:<buildTypeId>,branch:default:any,status:success/artifacts/content/<path>

/repository/download/BUILD_TYPE_ID/.lastSuccessful/ARTIFACT_PATH

My question is what is this artifact path? When I go to settings of the branch I want to download the artifact from it reads:

Artifact paths:

Output\C.Installer_*.exe

However when I append that path to the end of the url I get 

404

Artifact does not exist: 'Output/C.Installer_*.exe

 

Does anyone have any info on this? I've tried just about everything

1 comment
Comment actions Permalink

What do you get if you just request the following on your build?

<teamcity>/app/rest/builds/buildType:<buildTypeId>,branch:default:any,status:success/artifacts/children

This should return a list of artifacts and the content path to retrieve it. For example:

<files count="3">
<file name="index.html" size="480" modificationTime="20191126T115441-0600" href="/app/rest/builds/id:1229/artifacts/metadata/index.html">
<content href="/app/rest/builds/id:1229/artifacts/content/index.html"/>
</file>
<file name="README.md" size="10008" modificationTime="20191126T115441-0600" href="/app/rest/builds/id:1229/artifacts/metadata/README.md">
<content href="/app/rest/builds/id:1229/artifacts/content/README.md"/>
</file>
<file name="styles.css" size="273" modificationTime="20191126T115441-0600" href="/app/rest/builds/id:1229/artifacts/metadata/styles.css">
<content href="/app/rest/builds/id:1229/artifacts/content/styles.css"/>
</file>
</files>
 

Then, you can use the full content path appended to your <teamcity server> to download the file. Using the example above, I can download my README.md by using <teamcity server>/app/rest/builds/id:1229/artifacts/content/README.md

Our current documentation on using REST API to work with artifacts can be found here: https://www.jetbrains.com/help/teamcity/rest-api.html#Build-Artifacts

0

Please sign in to leave a comment.