diff --git a/src/main/java/org/dependencytrack/tasks/GitHubAdvisoryMirrorTask.java b/src/main/java/org/dependencytrack/tasks/GitHubAdvisoryMirrorTask.java index 7bc23cea5c..d90ee8ce83 100644 --- a/src/main/java/org/dependencytrack/tasks/GitHubAdvisoryMirrorTask.java +++ b/src/main/java/org/dependencytrack/tasks/GitHubAdvisoryMirrorTask.java @@ -112,6 +112,24 @@ public void inform(final Event e) { final long end = System.currentTimeMillis(); LOGGER.info("GitHub Advisory mirroring complete"); LOGGER.info("Time spent (total): " + (end - start) + "ms"); + + if (mirroredWithoutErrors) { + Notification.dispatch(new Notification() + .scope(NotificationScope.SYSTEM) + .group(NotificationGroup.DATASOURCE_MIRRORING) + .title(NotificationConstants.Title.GITHUB_ADVISORY_MIRROR) + .content("Mirroring of GitHub Advisories completed successfully") + .level(NotificationLevel.INFORMATIONAL) + ); + } else { + Notification.dispatch(new Notification() + .scope(NotificationScope.SYSTEM) + .group(NotificationGroup.DATASOURCE_MIRRORING) + .title(NotificationConstants.Title.GITHUB_ADVISORY_MIRROR) + .content("An error occurred mirroring the contents of GitHub Advisories. Check log for details.") + .level(NotificationLevel.ERROR) + ); + } } else { LOGGER.warn("GitHub Advisory mirroring is enabled, but no personal access token is configured. Skipping."); } @@ -159,24 +177,6 @@ private void retrieveAdvisories(final String advisoriesEndCursor) throws IOExcep retrieveAdvisories(pageableList.getEndCursor()); } } - - if (mirroredWithoutErrors) { - Notification.dispatch(new Notification() - .scope(NotificationScope.SYSTEM) - .group(NotificationGroup.DATASOURCE_MIRRORING) - .title(NotificationConstants.Title.GITHUB_ADVISORY_MIRROR) - .content("Mirroring of GitHub Advisories completed successfully") - .level(NotificationLevel.INFORMATIONAL) - ); - } else { - Notification.dispatch(new Notification() - .scope(NotificationScope.SYSTEM) - .group(NotificationGroup.DATASOURCE_MIRRORING) - .title(NotificationConstants.Title.GITHUB_ADVISORY_MIRROR) - .content("An error occurred mirroring the contents of GitHub Advisories. Check log for details.") - .level(NotificationLevel.ERROR) - ); - } } }