diff --git a/notifier/src/main/kotlin/modules/JiraNotifier.kt b/notifier/src/main/kotlin/modules/JiraNotifier.kt index 4a632e9d58287..f56bc2f84b03e 100644 --- a/notifier/src/main/kotlin/modules/JiraNotifier.kt +++ b/notifier/src/main/kotlin/modules/JiraNotifier.kt @@ -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 @@ -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]. */