Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make priority optional #69

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 '[email protected]' (**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