Skip to content

Commit

Permalink
JiraNotifier: Add function to get an issue
Browse files Browse the repository at this point in the history
The new function returns an issue for the given issue key which can be
used in the script to use specific attributes of it (e.g. reporter
of the issue).

Signed-off-by: Onur Demirci <[email protected]>
  • Loading branch information
bs-ondem authored and sschuberth committed Jan 25, 2022
1 parent 01d8385 commit def4677
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions notifier/src/main/kotlin/modules/JiraNotifier.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package org.ossreviewtoolkit.notifier.modules
import com.atlassian.jira.rest.client.api.JiraRestClient
import com.atlassian.jira.rest.client.api.domain.BasicIssue
import com.atlassian.jira.rest.client.api.domain.Comment
import com.atlassian.jira.rest.client.api.domain.Issue
import com.atlassian.jira.rest.client.api.domain.input.IssueInputBuilder
import com.atlassian.jira.rest.client.api.domain.input.TransitionInput
import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory
Expand Down Expand Up @@ -65,6 +66,19 @@ class JiraNotifier(
}.isSuccess
}

/**
* Return the issue for the given [issueKey].
*/
fun getIssue(issueKey: String): Issue? {
return runCatching {
restClient.issueClient.getIssue(issueKey).claim()
}.onFailure {
log.error {
"Could not retrieve the issue with the key '$issueKey' due to: ${it.collectMessagesAsString()}"
}
}.getOrNull()
}

/**
* Returns a [ProjectIssueBuilder] object, which can be used to do operations for the given [projectKey].
*/
Expand Down

0 comments on commit def4677

Please sign in to comment.