Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the last build artifact out of the TFS build drop?

Tags:

tfsbuild

Our existing batch build script contains an URL to get the latest product-build (of another build definition) from.

How can one access the lattest build drop folder of TFS Team Build?

I'm looking for something to access the latest \buildserver\builddrop\Project-2010MMDD.N\

like image 339
flubba Avatar asked Jun 07 '10 14:06

flubba


People also ask

Where are build 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.

What is the release artifact?

A release is a collection of artifacts in your DevOps CI/CD processes. An artifact is a deployable component of your application. Azure Pipelines can deploy artifacts that are produced by a wide range of artifact sources, and stored in different types of artifact repositories.

What is artifact DevOps?

A DevOps artifact is a by-product produced during the software development process. It may consist of the project source code, dependencies, binaries or resources, and could be represented in different layout depending on the technology.


1 Answers

Using the API, you can get the drop location from the build. The code below gets the most recent build for a given project, and returns the dropfolder.

public string DropFolder(TeamFoundationServer tfs, string teamProject, string buildName)
{
    IBuildServer buildServer = (IBuildServer)tfs.GetService(typeof(IBuildServer));

    IBuildDetailSpec buildDetailSpec = buildServer.CreateBuildDetailSpec(teamProject, buildName);

    buildDetailSpec.MaxBuildsPerDefinition = 1;
    buildDetailSpec.QueryOrder = BuildQueryOrder.FinishTimeDescending;
    buildDetailSpec.Status = BuildStatus.Failed | BuildStatus.PartiallySucceeded | BuildStatus.Stopped | BuildStatus.Succeeded;

    IBuildQueryResult results = buildServer.QueryBuilds(buildDetailSpec);

    if (results.Failures.Length != 0)
    {
        throw new ApplicationException("this needs to go away and be handled more nicely");
    }

    if (results.Builds.Length == 1)
    {
        results.Builds[0].DropLocation;
    }
    else
    {
        return null;
    }
}
like image 72
Robaticus Avatar answered Oct 24 '22 13:10

Robaticus