Example #1
0
        public static async Task CreateJiraIssue(CreateIssueSettings settings, ICakeLog logger)
        {
            try
            {
                logger.Information($"Creating jira issue '{settings.Summary}' on {settings.Project}");

                var jira          = CreateJira(settings);
                var issueSettings = new CreateIssueFields(settings.Project);

                var issue = new Issue(jira, issueSettings)
                {
                    Reporter    = settings.Reporter,
                    Summary     = settings.Summary,
                    Description = settings.Description,
                    Environment = settings.Environment,
                    Assignee    = settings.Assignee,
                    DueDate     = settings.DueDate
                };

                if (settings.Priority != 0)
                {
                    issue.Priority = new IssuePriority(settings.Priority.ToString(CultureInfo.InvariantCulture));
                }

                if (settings.Type != 0)
                {
                    issue.Type = new IssueType(settings.Type.ToString(CultureInfo.InvariantCulture));
                }

                if (settings.Labels != null)
                {
                    issue.Labels.AddRange(settings.Labels);
                }

                var createdIssueKey = await issue.Jira.Issues.CreateIssueAsync(issue);

                if (!string.IsNullOrEmpty(createdIssueKey))
                {
                    logger.Information($"Jira issue '{settings.Summary}' created with key: " + createdIssueKey);
                }
                else
                {
                    logger.Information($"Unable to create jira issue '{settings.Summary}'");
                }
            }
            catch (Exception ex)
            {
                logger.Error($"Error creating issue '{settings.Summary}': {ex.Message}");
            }
        }
Example #2
0
        public static async Task CreateJiraIssue(this ICakeContext context, CreateIssueSettings settings)
        {
            ValidateJiraSettings(settings);

            if (string.IsNullOrWhiteSpace(settings.Project))
            {
                throw new ArgumentException("Project must be specified.");
            }

            if (string.IsNullOrWhiteSpace(settings.Summary))
            {
                throw new ArgumentException("Summary must be specified.");
            }

            await JiraClient.CreateJiraIssue(settings, context.Log);
        }