public CreateIssueResponse CreateIssue(IssueCreation issueCreation) { var request = new RestRequest(IssueEndpoint); request.AddHeader("Content-Type", "application/json"); request.AddJsonBody(issueCreation); var content = restClient.Post(request).Content; return(JsonConvert.DeserializeObject <CreateIssueResponse>(content)); }
public Issue CreateTestCase(IssueCreation issueCreation) { var issues = _jiraCloudApi.QueryIssueKeys(issueCreation.fields.summary, true); if (issues != null && issues.Count > 0) { var issueKeys = string.Join(", ", issues.ToArray()); Debug.WriteLine($"Test case with summary \"{issueCreation.fields.summary}\" already exists as {issueKeys} in Jira"); return(_jiraCloudApi.GetIssue(issues.First())); } var createdIssue = _jiraCloudApi.CreateIssue(issueCreation); Debug.WriteLine($"Test case with summary \"{issueCreation.fields.summary}\" was created as {createdIssue.Key} in Jira"); return(createdIssue); }
public Issue CreateIssue(IssueCreation issueCreation) { var source = $"{JiraSource}/issue"; var response = SendHttpRequest(source, Method.POST, issueCreation); if (response == null) { return(null); } return(new Issue { Id = (long)response[Id], Key = (string)response[Key], Summary = issueCreation.fields.summary, ProjectId = Project.Id }); }
public Issue CreateTestCase(string projectKey, IssueInCycle issueInCycle, string reporter = null) { Issue issue = null; try { var description = $"Please refer to automation test - {issueInCycle.TestName}()"; // step 1, create a test case in Jira if (string.IsNullOrWhiteSpace(issueInCycle.Key)) { var issueCreation = new IssueCreation { fields = new Fields { project = new ProjectField { key = projectKey }, summary = issueInCycle.TestSummary, description = description, issuetype = new Issuetype { name = "Test" }, reporter = new Reporter { name = reporter }, labels = issueInCycle.Labels } }; issueInCycle.Overwritten = false; issue = CreateTestCase(issueCreation); } else // step 1, update a test case in Jira { var issueUpdate = new IssueUpdate { fields = new UpdateFields { description = description, labels = issueInCycle.Labels, summary = issueInCycle.TestSummary } }; issueInCycle.Overwritten = true; issue = UpdateTestCase(issueInCycle.Key, issueUpdate); } if (issue != null) { // step 2, add test steps to the issue in Zephyr if (issueInCycle.Steps != null && issueInCycle.Steps.Count > 0) { AddStepsToTestCase(issue.Key, issueInCycle.Steps, issueInCycle.Overwritten); } // step 3, add the test case to the constrain of version-cycles if (issueInCycle.CycleNames != null && issueInCycle.CycleNames.Count > 0) { if (!string.IsNullOrWhiteSpace(issueInCycle.VersionName)) { var version = GetReleaseVersion(issueInCycle.VersionName); if (version != null) { foreach (var cycleName in issueInCycle.CycleNames) { var cycle = GetTestCycle(version.Id, version.ProjectId, cycleName); if (cycle != null) { AddTestCaseToCycle(issue, cycle); } } } } } } return(issue); } catch (Exception e) { Debug.WriteLine($"Create test {issueInCycle.TestName} in Jira failed at: {e.Message}"); return(issue); } }