捕获 VersionReleaseEvent 时如何从发布(修复版本)中获取问题列表

How to get list of issues from a release (fix version) when capturing VersionReleaseEvent

我正在实现一个 Jira Server 插件,它带有一个监听器,可以捕获每个 VersionReleaseEvent:

@EventListener
public void onVersionReleaseEvent(VersionReleaseEvent versionReleaseEvent) {
    log.info("#### onVersionReleaseEvent {}", versionReleaseEvent);
}

我需要知道该 versionRelease 中包含哪些问题,但 VersionReleaseEvent class 不包含它们。我如何访问该信息?

我终于设法解决了这个问题,使用 JQL 和 SearchService:

@Component
public class ReleaseVersionListener implements InitializingBean, DisposableBean {
    private static final Logger log = LoggerFactory.getLogger(ReleaseVersionListener.class);

    @JiraImport
    private final EventPublisher eventPublisher;

    @JiraImport
    private SearchService searchService;

    @JiraImport
    private JiraAuthenticationContext jiraAuthenticationContext;

    @ComponentImport
    private final PluginSettingsFactory pluginSettingsFactory;

    private final RestTemplate restTemplate = new RestTemplate();

    @Autowired
    public ReleaseVersionListener(EventPublisher eventPublisher, JiraAuthenticationContext jiraAuthenticationContext, PluginSettingsFactory pluginSettingsFactory,
                                  SearchService searchService) {
        this.eventPublisher = eventPublisher;
        this.pluginSettingsFactory = pluginSettingsFactory;
        this.searchService = searchService;
        this.jiraAuthenticationContext = jiraAuthenticationContext;
    }

    @EventListener
    public void onVersionReleaseEvent(VersionReleaseEvent versionReleaseEvent) {
        log.info("#### onVersionReleaseEvent {}", versionReleaseEvent);
        String projectId = versionReleaseEvent.getVersion().getProject().getName();
        ApplicationUser loggedInUser = jiraAuthenticationContext.getLoggedInUser();
        JqlClauseBuilder jqlClauseBuilder = JqlQueryBuilder.newClauseBuilder();
        Query query = jqlClauseBuilder.fixVersion().in().functionReleasedVersions(projectId).buildQuery();
        PagerFilter<?> pagerFilter = PagerFilter.getUnlimitedFilter();
        try {
            SearchResults results = searchService.search(loggedInUser, query, pagerFilter);
            List<Issue> issues = results.getIssues();

            List<Issue> releasedIssues = issues.stream()
                    .filter(i -> i.getFixVersions().iterator().next().getName().equalsIgnoreCase(versionReleaseEvent.getVersion().getName()))
                    .collect(Collectors.toList());
        ...
    }