I have TFS 2015 RC2 installed on-premise. I\'m trying to use REST API to queue a build in a vNext definiton.
I\'m using the code sample from VSO with slight modifica
TFS 2015 RC2 uses a new API (version 2.0-preview.2). The VSO sample I mentioned in the question is outdated and not relevant when you wish to queue a new build.
Currently, there is no documentation but the web portal uses REST API so just Fiddler away.
Here is the code:
var buildRequestPOSTData =
new BuildRequest()
{
Definition = new Definition()
{
Id = firstBuildDefinition.Id
},
Project = new Project { Id = "project guid" },
Queue = new Queue { Id = 1 },
Reason = 1,
sourceBranch = "$Branch"
};
responseBody = await QueueBuildAsync(client, buildRequestPOSTData, _baseUrl + "build/Builds");
And here is the class with new parameters for build requests:
public class BuildRequest
{
[JsonProperty(PropertyName = "definition")]
public Definition Definition { get; set; }
[JsonProperty(PropertyName = "demands")]
public string Demands { get; set; }
[JsonProperty(PropertyName = "parameters")]
public IEnumerable Parameters { get; set; }
[JsonProperty(PropertyName = "project")]
public Project Project { get; set; }
[JsonProperty(PropertyName = "queue")]
public Queue Queue { get; set; }
[JsonProperty(PropertyName = "reason")]
public int Reason { get; set; }
[JsonProperty(PropertyName = "sourceBranch")]
public string sourceBranch { get; set; }
[JsonProperty(PropertyName = "sourceVersion")]
public string RequestedBy { get; set; }
}
public class Definition
{
[JsonProperty(PropertyName = "id")]
public int Id { get; set; }
}
public class Queue
{
[JsonProperty(PropertyName = "id")]
public int Id { get; set; }
}
public class Project
{
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }
}