Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
async Task Main()
{
var apiKey = "Input your Api Key";
var orgId = "Input Target OrgId";
var projectId = "Input ProjectId";
var client = new UnityCloudBuildApi.IO.Swagger.Client.ApiClient("https://build-api.cloud.unity3d.com/api/v1");
var config = new UnityCloudBuildApi.IO.Swagger.Client.Configuration(client, accessToken: apiKey);
#region Build Api
// Get Build Detail
var buildApi = new UnityCloudBuildApi.IO.Swagger.Api.BuildsApi(config);
var build = await buildApi.GetBuildsAsync(orgId, projectId, buildTargets.FirstOrDefault().Buildtargetid);
// Start Build
var option = new UnityCloudBuildApi.IO.Swagger.Model.Options4
{
Clean = false,
Delay = 0,
};
var startBuild = await buildApi.StartBuildsAsync(orgId, projectId, buildTargets.FirstOrDefault().Buildtargetid, option);
startBuild.Dump();
// Cancel All Build
foreach (var item in build.Where(x => x.BuildStatus == "queued"))
{
var cancelBuilds = await buildApi.CancelAllBuildsAsync(orgId, projectId, item.Buildtargetid);
}
// Cancel Specific Builds
var cancelBuild = await buildApi.CancelBuildAsync(orgId, projectId, buildTargets.FirstOrDefault().Buildtargetid, startBuild.FirstOrDefault().Build.ToString());
#endregion
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment