Skip to content

Commit

Permalink
Make priority optional
Browse files Browse the repository at this point in the history
  • Loading branch information
arnested committed Apr 16, 2024
1 parent 7904da8 commit bca171c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions src/JiraSecurityIssue.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class JiraSecurityIssue
/**
* Priority of issue to create.
*/
protected string $priority = 'Undecided';
protected ?string $priority = null;

/**
* Type of issue to create.
Expand Down Expand Up @@ -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';

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit bca171c

Please sign in to comment.