diff --git a/README.md b/README.md index e13c996..669964f 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ CI systems. - `JIRA_USER`: The ID of the Jira user which is associated with the 'JiraApiToken' secret, eg 'someuser@reload.dk' (**REQUIRED**) - `JIRA_PROJECT`: The project key for the Jira project where issues should be created, eg `TEST` or `ABC`. (**REQUIRED** if not set in code) - `JIRA_ISSUE_TYPE`: Type of issue to create, e.g. `Security`. Defaults to `Bug`. (*Optional*) +- `JIRA_PRIORITY`: The priority of issue to create, e.g. `Critical`. (*Optional*) - `JIRA_WATCHERS`: Jira users to add as watchers to tickets. Separate multiple watchers with comma (no spaces). (*Optional*) - `JIRA_RESTRICTED_COMMENT_ROLE`: A comment with restricted visibility diff --git a/src/JiraSecurityIssue.php b/src/JiraSecurityIssue.php index ee8e32f..4323857 100644 --- a/src/JiraSecurityIssue.php +++ b/src/JiraSecurityIssue.php @@ -43,7 +43,7 @@ class JiraSecurityIssue /** * Priority of issue to create. */ - protected string $priority = 'Undecided'; + protected ?string $priority = null; /** * Type of issue to create. @@ -82,7 +82,7 @@ class JiraSecurityIssue public function __construct() { $this->project = \getenv('JIRA_PROJECT') ?: ''; - $this->priority = \getenv('JIRA_PRIORITY') ?: 'Undecided'; + $this->priority = \getenv('JIRA_PRIORITY') ?: null; $this->issueType = \getenv('JIRA_ISSUE_TYPE') ?: 'Bug'; $this->restrictedCommentRole = \getenv('JIRA_RESTRICTED_COMMENT_ROLE') ?: 'Developers'; @@ -202,10 +202,13 @@ public function ensure(): string $issueField = new IssueField(); $issueField->setProjectKey($this->project) ->setSummary($this->title ?? '') - ->setPriorityNameAsString($this->priority) ->setIssueTypeAsString($this->issueType) ->setDescription($this->body); + if (\is_string($this->priority)) { + $issueField->setPriorityNameAsString($this->priority); + } + foreach ($this->keyLabels as $label) { $issueField->addLabelAsString($label); }