How to get a reference to the previous build from the current build?


I have a build process that implements jetbrains.buildServer.agent.BuildProcess. My task is to compare certain results of the test that are stored in an artifact for each build.

I've attached an image showing 3 successful builds. Say that build #14 is about to end and we need to compare the current test results with those in build #13 regardless of which agent #13 was executed on. As mentioned the test results are stored in an artifact of each build.

Is there a way to access the artifact of the previous build from the currently running build?

Thanks for your help,



> Is there a way to access the artifact of the previous build from the currently running build?

It is possible, but the approach would be different depending on the location of the logic: agent-side plugin / build script or the server-side plugin.

For the agent-side plugin you can use TeamCity REST API call to download artifacts from the last finished build.

The request can be something like <TeamCity server URL>/app/rest/builds/buildType:(id:<buildTypeId>),branch:(name:<branchName>)/artifacts/content/<buildArtifactPath>
",branch:(name:<branchName>" can be dropped for the build on default branch.
However, you need to provide valid authenticatin with the request. Build's authentication will probbaly work for this case.


Yegor, great, thanks a lot, I'll test that approach.


...I have a follow up question. How can an agent discover the TeamCity server URL, such as



Each build has "teamcity.serverUrl" configuration parameter with the server URl
From the API you can use AgentConfiguration.getServerUrl()


Hi Andras,

You said that you have given a try to use the API and implement at agent side using REST API.

Currently we have a requirement to update the management related excel automatically based on build results.

For this i am looking how can i/what is the procedure to use REST API in teamcity. 

Could you please share your thoughts or some coding snippets to achieve this.


Please sign in to leave a comment.