download last finished artifacts from latest build (any branch)
Completed
How can you download the latest build artifacts from *any* branch?
Please note if you use the following it downloads from the default branch
/httpAuth/repository/downloadAll/$buildId/.lastFinished/
I know you can use this syntax but it means you need to know the branch name in the downstream script
/httpAuth/repository/downloadAll/$buildId/.lastFinished/?branch=$branch"
Also 'last finished' should really be the last finished irrespective of the branch.
Please sign in to leave a comment.
Hello!
Could you please provide a bit more details on your use case (i.e. why last finished build from any branch is required?) and TeamCity version you have installed?
This behaviour is by design; during implementation it has been considered that a build from default branch is required unless explicitly stated otherwise. There is a workaround, though, which I was just able to confirm working:
/httpAuth/app/rest/builds/buildType:(<buildConfId>),state:finished,count:1,branch:default:any/artifacts
This is a REST API call (https://www.jetbrains.com/help/teamcity/rest-api.html) which is generally suggested over the approach you are currently using. Specifically, a default branch filter which is implicitly used is being turned off, allowing any branches to be included into build locator. We are limiting builds for a buildConfID which are finished and the count of builds to be shown is 1 (essentially, last finished build from any branch under specified configuration).
Please let me know if this works for you or if you`d like any details on the above.
Hi Fedor, we are using
>TeamCity Professional 2019.2.2 (build 71923)
The use-case is the following:
We are performing an on-demand build (compile) of a product that is immediately deployed. The build may use the default or any branch.
The deployment script fetches the artifacts from TeamCity and as I described above the script is liable to fetch an old build on the default branch instead of the 'last finished'
Its probably ok now I have changed the deployment script to include the branch name - I am wondering how your call works, specifically this
>a default branch filter which is implicitly used is being turned off
how?
Thank you
This part of endpoint:
buildType:(<buildConfId>),state:finished,count:1,branch:default:any
is a build locator; essentially, a statement which allows to fetch single instance or a collection of items, builds in this case. Please note the latter part of locator:
branch:default:any
The branch locator part allows to set a specific branch we`ll try to fetch build for. It has multiple options for initialization, with one being to specify default subpart. It allows the following values: true, false, any (respectively, limiting all output to default branch, limiting output to everything but default branch, and allowing just any branch). The latter appears to cover the requirement best. You can find more details on the build locators here: https://www.jetbrains.com/help/teamcity/rest-api.html#RESTAPI-BuildRequests
Thank you very much Fedor, A grade support as usual from Jetbrains