private string getJobId() { // TODO: // this is still hacky, for some reason 'pr=false' doesn't do anything?? // so for now just hope that one of the last 100 builds will be not a PR :) // ref https://github.com/appveyor/ci/issues/3155 string url = $"{apiUrl}/projects/{project}/history?recordsNumber=100&branch={branch}&pr=false"; ProjectHistory history = JsonConvert.DeserializeObject <ProjectHistory>(getApiData(url)); // find successful build foreach (Build b in history.Builds) { // skip pull requests if (b.PullRequestId != null) { continue; } if (b.Status == "success") { string url2 = $"{apiUrl}/projects/{project}/build/{b.Version}"; return(JsonConvert.DeserializeObject <BuildInfo>(getApiData(url2)).Build.Jobs[0].JobId); } } throw new Exception($"No successful builds found for '{project}'!"); }
private string getJobId() { string url = $"{apiUrl}/projects/{project}/history?recordsNumber=5&branch={branch}"; ProjectHistory history = JsonConvert.DeserializeObject <ProjectHistory>(getApiData(url)); // find successful build foreach (Build b in history.Builds) { if (b.Status == "success") { string url2 = $"{apiUrl}/projects/{project}/build/{b.Version}"; return(JsonConvert.DeserializeObject <BuildInfo>(getApiData(url2)).Build.Jobs[0].JobId); } } throw new Exception($"No successful builds found for '{project}'!"); }
private string getJobId(string artifactName = null) { string url = $"{apiUrl}/projects/{project}/history?recordsNumber=5&branch={branch}"; ProjectHistory history = JsonConvert.DeserializeObject <ProjectHistory>(getApiData(url)); // find successful build foreach (Build b in history.Builds) { if (b.Status == "success") { string url2 = $"{apiUrl}/projects/{project}/build/{b.Version}"; // find artifact with artifact name, // else just return the first artifact if (artifactName != null) { foreach (Jobs j in JsonConvert.DeserializeObject <BuildInfo>(getApiData(url2)).Build.Jobs) { if (j.Name == artifactName) { return(j.JobId); } } throw new Exception($"No artifact with name '{artifactName}' was found!"); } else { return(JsonConvert.DeserializeObject <BuildInfo>(getApiData(url2)).Build.Jobs[0].JobId); } } } throw new Exception($"No successful builds found for '{project}'!"); }