3

Is there a way to download specific builds of a project in TeamCity?

kasperhj
  • 10,052
  • 21
  • 63
  • 106

5 Answers5

8

You can use the build id, build number or one of the static build identifiers:

http://{TeamCity-Server}/repository/download/{BUILD_TYPE_ID}/{BUILD_NUMBER}/{ARTIFACT_PATH}

http://confluence.jetbrains.net/display/TCD65/Patterns+For+Accessing+Build+Artifacts

Bronumski
  • 14,009
  • 6
  • 49
  • 77
  • How do I set up TC to do this? Can it provide a listing of the different builds? – kasperhj Jul 13 '11 at 09:47
  • @lejon Can we confirm what it is you are trying to download. I got the impression that you are trying to download artifacts from a build, is this the case? – Bronumski Jul 13 '11 at 10:46
  • I'm sorry, I don't know what "artifacts" referes to. – kasperhj Jul 13 '11 at 11:54
  • @lejon What do you want to download, the output from a build or the source used for the build? – Bronumski Jul 13 '11 at 14:24
  • Both really. First the output though. – kasperhj Jul 13 '11 at 17:10
  • @lejon In order to get the output you need to store the output as artifacts. http://confluence.jetbrains.net/display/TCD65/Build+Artifact Once you have artifacts you can access them how I described above. – Bronumski Jul 14 '11 at 10:02
3

What you're actually looking to do is create artifacts in TeamCity. Artifacts are normally a build output which are then attached to the individual build runs so that you can download and review them at a later date. There's a walk through including the creation of build artifacts in You're deploying it wrong! TeamCity, Subversion & Web Deploy part 5: Web Deploy with TeamCity.

Joey
  • 670
  • 8
  • 14
Troy Hunt
  • 20,345
  • 13
  • 96
  • 151
  • I have now tried adding some artifact paths to put the content of \bin in a separate directory (although the path is rather obscure). How can I reference this artifact from the outside, so my users always can download the latest version by entering a url? – kasperhj Jul 18 '11 at 14:13
  • I'm not near a TeamCity server this week so I'll have to speculate, but I think you'll find the URL is predictable and will contain a variable for the build number. There's also a REST API available that can be used to pull back build info which you might find useful: http://confluence.jetbrains.net/display/TW/REST+API+Plugin – Troy Hunt Jul 18 '11 at 20:33
0

To get latest successful build artifacts from Team City you can use the following link templates:

  • with guest authentication: http://<buildServer>/guestAuth/downloadArtifacts.html?buildTypeId=<buildTypeId>&buildId=lastSuccessful

  • with your credentials: http://<buildServer>/repository/downloadAll/<buildTypeId>/.lastSuccessful/artifacts.zip

  • with specific artifact: http://<buildServer>/httpAuth/repository/download/<buildTypeId>/.lastSuccessful/<some file.ext>

Oleg Tatarchuk
  • 101
  • 1
  • 3
0

As mentioned above, one can download using REST API. It is also possible using FluentTc library with fluent api:

Download artifacts of the latest successful build:

IConnectedTc connectedTc = new RemoteTc().Connect(a => a.ToHost("tc")
       .AsUser("MYUSERNAME", "MYPASSWORD"))

IBuild lastSuccessfulBuild = connectedTc.GetLastBuild(having => 
    having.BuildConfiguration(with => with.Id("FluentTc"))
    .Status(BuildStatus.Success));

IList<string> downloadedFiles = connectedTc.DownloadArtifacts(lastSuccessfulBuild.Id, 
            @"C:\DownloadedArtifacts");

Download specific file from artifacts of specific build by build Id:

string downloadedFile = connectedTc.DownloadArtifacts(
    buildId, 
    @"C:\DownloadedArtifacts", 
    "binaries.zip");
Boris Modylevsky
  • 3,029
  • 1
  • 26
  • 42
0

we attach the .msi file generated from the build as an artifact containing the build number (you can use %env.BUILD_NUMBER% to find the artifact path).

ravyoli
  • 698
  • 6
  • 13