0

How can one determine the custom parameter values that were used during a TFS build?

Breakskater
  • 415
  • 1
  • 4
  • 18

1 Answers1

1

You can achieve that via using TFS API, check the following code:

TfsTeamProjectCollection tfctc = new TfsTeamProjectCollection(new Uri("http://tfsservername:8080/tfs/DefaultCollection"));
        IBuildServer bs = tfctc.GetService<IBuildServer>();

        IBuildDetail[] builds = bs.QueryBuilds("teamprojectname", "builddefinitionname");
        foreach (var build in builds)
        {
            var buildefinition = build.BuildDefinition;
            IDictionary<String, Object> paramValues = WorkflowHelpers.DeserializeProcessParameters(buildefinition.ProcessParameters);
            string processParametersValue = paramValues["argument1"].ToString();
            Console.WriteLine(processParametersValue);
        }
Vicky - MSFT
  • 4,970
  • 1
  • 14
  • 22
  • Thanks. Are the parameter values displayed in the UI or build log somewhere? – Breakskater Sep 20 '15 at 03:22
  • 1
    @Breakskater, code above prints argument1 on the console. What is your detailed requirement? Where you would like to get/show the value of the parameter? – Vicky - MSFT Sep 21 '15 at 01:34
  • I need to rephrase my question. Do you know if build parameter values used are readily available in the project portal or build history/logs as a native feature of TFS without writing any code? – Breakskater Sep 21 '15 at 02:19
  • 1
    @Breakskater, if you like, you can show the parameter value in build log. Instead of coding, it is achieved via customizing the TFS build process template. Please check this blog for the complete steps: http://www.ewaldhofman.nl/post/2010/04/27/Customize-Team-Build-2010-e28093-Part-2-Add-arguments-and-variables.aspx – Vicky - MSFT Sep 21 '15 at 02:36
  • Thanks. I'm assuming it's not already in the build log or UI somewhere, correct? – Breakskater Sep 29 '15 at 03:28