コード例 #1
0
        /// <summary>
        /// Creates a new JIRA issue (a bug).
        /// </summary>
        /// <param name="projectKey">The projects key e.g. TSCB.</param>
        /// <param name="bugTitle">The title of the bug.</param>
        /// <param name="bugDescription">The detailed description of the bug.</param>
        /// <param name="bugPriority">The priority of the bug.</param>
        /// <param name="bugCreatedDate">The date the bug was created.</param>
        /// <param name="bugAuthor">The author of the bug.</param>
        /// <param name="bugAssignedTo">The person/group the bug is assigned to.</param>
        /// <param name="bugAttachments">List of files to attach to the bug.</param>
        /// <param name="error">Any errors during bug creation are written here.</param>
        /// <returns>The key of the bug e.g. TSCB-14</returns>
        public string SubmitBug(string projectKey, string bugTitle, string bugDescription, int bugPriority, DateTime bugCreatedDate,
                                string bugAuthor, string bugAssignedTo, List <IBugAttachment> bugAttachments, out string error)
        {
            JiraIssue jiraIssue = new JiraIssue();

            jiraIssue.fields.issuetype.name = "Bug";
            jiraIssue.fields.project.key    = projectKey;
            jiraIssue.fields.summary        = bugTitle;
            jiraIssue.fields.description    = bugDescription;
            //jiraIssue.Fields.Priority.Id = 1;

            JToken result = JiraComm.PostJson(this.Server, "/rest/api/2/issue/", this.User, this.Password, JsonConvert.SerializeObject(jiraIssue), out error);

            // Make sure the issue was successfully created before attaching files
            if (null != result)
            {
                JiraIssueCreated createdIssue = new JiraIssueCreated();
                JsonConvert.PopulateObject(result.ToString(), createdIssue);

                foreach (IBugAttachment attachment in bugAttachments)
                {
                    AttachFile(this.Server, this.User, this.Password, createdIssue.key, attachment, out error);
                    // Break if there was an error attaching this file
                    if (null != error)
                    {
                        break;
                    }
                }

                return(createdIssue.key);
            }
            return(null);
        }
コード例 #2
0
ファイル: JiraComm.cs プロジェクト: TestStudio/JiraPlugin
        /// <summary>
        /// Creates a new JIRA issue (a bug).
        /// </summary>
        /// <param name="projectKey">The projects key e.g. TSCB.</param>
        /// <param name="bugTitle">The title of the bug.</param>
        /// <param name="bugDescription">The detailed description of the bug.</param>
        /// <param name="bugPriority">The priority of the bug.</param>
        /// <param name="bugCreatedDate">The date the bug was created.</param>
        /// <param name="bugAuthor">The author of the bug.</param>
        /// <param name="bugAssignedTo">The person/group the bug is assigned to.</param>
        /// <param name="bugAttachments">List of files to attach to the bug.</param>
        /// <param name="error">Any errors during bug creation are written here.</param>
        /// <returns>The key of the bug e.g. TSCB-14</returns>
        public string SubmitBug(string projectKey, string bugTitle, string bugDescription, int bugPriority, DateTime bugCreatedDate,
            string bugAuthor, string bugAssignedTo, List<IBugAttachment> bugAttachments, out string error)
        {
            JiraIssue jiraIssue = new JiraIssue();
            jiraIssue.fields.issuetype.name = "Bug";
            jiraIssue.fields.project.key = projectKey;
            jiraIssue.fields.summary = bugTitle;
            jiraIssue.fields.description = bugDescription;
            //jiraIssue.Fields.Priority.Id = 1;

            JToken result = JiraComm.PostJson(this.Server, "/rest/api/2/issue/", this.User, this.Password, JsonConvert.SerializeObject(jiraIssue), out error);
            // Make sure the issue was successfully created before attaching files
            if (null != result)
            {
                JiraIssueCreated createdIssue = new JiraIssueCreated();
                JsonConvert.PopulateObject(result.ToString(), createdIssue);

                foreach (IBugAttachment attachment in bugAttachments)
                {
                    AttachFile(this.Server, this.User, this.Password, createdIssue.key, attachment, out error);
                    // Break if there was an error attaching this file
                    if (null != error)
                    {
                        break;
                    }
                }

                return createdIssue.key;
            }
            return null;
        }