0

I am working on a build controller ot assist in the management of builds and deployments. In this process, it is necessary for me to specify the changeset number for the build. In the Build Configuration, when doing this manually, it is identical to setting the "Get Version" parameter in Process | Advanced.

When I set this value in the UI, I can then modify it when I get the build definition. The modification which I make causes the build to work as expected.

When Get Version is left blank, and I repeat the test, loading the params via code, I always get the latest version, as though the changeset is not being specified.

Here is my code:

    foreach (IBuildDefinition def in BuildDefinitions.SelectedItems)
{
    var process = WorkflowHelpers.DeserializeProcessParameters(def.ProcessParameters);                     
    process.Add("GetVersion", "C1111");
    // process["GetVersion"] = "C1133";
    def.ProcessParameters = WorkflowHelpers.SerializeProcessParameters(process);
    IQueuedBuild result = buildServer.QueueBuild(def);
}

It appears that the build definition may contain a different value between the two cases, but I am unable to locate it.

What am I missing?

JamieMeyer
  • 386
  • 3
  • 14

1 Answers1

0

The this instead:

var request = def.CreateBuildRequest();
request.GetOption = GetOption.Custom;
request.CustomGetVersion = "C1234";
server.QueueBuild(request);

The documentation for IBuildServer.QueueBuild(IBuildDefinition) says:

Queues a build for the specified build definition with all default options.

I am guessing that it is not using most of the parameters from the definition passed in.

Actually, thinking about it, setting the params on the request makes sense, this is your build request, you're not changing the definition.

DaveShaw
  • 52,123
  • 16
  • 112
  • 141
  • I tested this code, and it did not yield the correct changeset. It executed the build, and delivered against the most recent changeset. – JamieMeyer Aug 27 '13 at 13:19
  • 1
    Dave - I read your response another 5 times, and figured out the answer, based on your response. Apparently, I did not try your code verbatim, and I was still queuing the def, and not the request. Thanks. – JamieMeyer Sep 02 '13 at 00:14
  • @JamieMeyer - I didn't know what else to try, I didn't have time to test this, but I got it from reverse engineering TFSBuild.exe ;) – DaveShaw Sep 02 '13 at 14:57
  • The fundamental concept that I missed, and that I calling out for others to learn from is that through the UI, when queuing a build, you are queuing a build request, not a build definition. After I figured that out, all of the pieces of the puzzle fit in to place. That is not pointed out anywhere that I could find, hence my confusion. – JamieMeyer Sep 05 '13 at 00:33