Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TeamCity artifact from lastSuccessful branch build

Tags:

teamcity

I recently re-configured our TeamCity build configuration to take advantage of the Branch features to apply the same build configuration to multiple branches in the same repository.

Now, I'm trying to setup an automated build script that can pull the latest artifact from TeamCity, but only for a specific branch. I was able to get it working fine on the default branch in the original configuration, using the TeamCity REST API, but can't figure out how to format the URL to pull the artifact for a specific branch.

I've looked at the following resources, but to no avail:

http://confluence.jetbrains.com/display/TW/REST+API+Plugin http://confluence.jetbrains.com/display/TCD7/Patterns+For+Accessing+Build+Artifacts

Thoughts?

like image 233
jeremyalan Avatar asked Jul 12 '13 23:07

jeremyalan


People also ask

Where are TeamCity artifacts stored?

By default, the artifacts are stored under the <TeamCity Data Directory\>/system/artifacts directory which can be changed. You can configure an external artifacts storage to replace the built-in one. Build artifacts can also be uploaded to the server while the build is still running.

How do you download artifacts on TeamCity?

You can also download artifacts from TeamCity using the Ivy dependency manager. For artifact downloads from outside TeamCity builds, consider using REST API. See also Accessing Server by HTTP on basic rules covering an HTTP access from scripts.

What is artifact path in TeamCity?

Artifact Paths Build artifacts are files produced by the build which are stored on TeamCity server and can be downloaded from the TeamCity UI or used as artifact dependencies by other builds.

What is build locator in TeamCity?

BuildLocator Last modified: 21 September 2022. Represents a locator string for filtering Build entities. Examples: id:1 — find build with ID 1 .


2 Answers

From the linked page adding the QueryString param worked for me:

?branch=<branch_name>

Without this it only downloads artifacts from default branch.

Our full url:

http://<buildserver>/repository/downloadAll/<BuildId>/.lastFinished?branch=<branchname>

Which will download latest build from branch 'branchname' on the 'buildid' config.

like image 176
Henk J Meulekamp Avatar answered Nov 21 '22 16:11

Henk J Meulekamp


I just came across this article.

I plan on giving this a try over the next couple days, and if it works, I will give a brief summary of the result for anyone else who has trouble with this.

EDIT:

Sorry for the delay, just realized that I never came back to report how we resolved this issue.

We ended up upgrading TeamCity (which we should have done anyway, so it wasn't a big deal), and once that was finished, it worked great without much effort. We're now running TeamCity v8.1.5, and here's the URL pattern we're using to pull our artifacts:

http://<build-server>/httpAuth/app/rest/builds/buildType:<build-type>,branch:<branch>/artifacts/content/<artifact-path>

NOTE: We're using the httpAuth API in order to authorize access to our build artifacts, so we also had to create a new TeamCity user for our deployments.

like image 36
jeremyalan Avatar answered Nov 21 '22 16:11

jeremyalan