use of com.microfocus.octane.gitlab.testresults.TestResultsCleanUpRunnable in project octane-gitlab-service by MicroFocus.
the class GitlabServices method init.
@PostConstruct
private void init() throws MalformedURLException {
// Adding webHooks
initWebHookListenerURL();
gitLabApi = gitLabApiWrapper.getGitLabApi();
try {
List<Project> projects = isCurrentUserAdmin() ? gitLabApi.getProjectApi().getProjects() : gitLabApi.getProjectApi().getMemberProjects();
User currentUser = gitLabApi.getUserApi().getCurrentUser();
if (cleanupOnly) {
log.info("start with cleanup process");
for (Project project : projects) {
if (gitLabApiWrapper.isUserHasPermissionForProject(project, currentUser)) {
deleteWebHooks(project.getId());
}
}
} else {
for (Project project : projects) {
if (gitLabApiWrapper.isUserHasPermissionForProject(project, currentUser)) {
addWebHookToProject(project.getId(), true);
}
}
}
} catch (GitLabApiException e) {
log.warn("Failed to create GitLab web hooks", e);
throw new RuntimeException(e);
}
// start cleanUp thread
executor = Executors.newSingleThreadScheduledExecutor();
executor.scheduleAtFixedRate(new TestResultsCleanUpRunnable(applicationSettings.getConfig().getTestResultsOutputFolderPath()), TestResultsCleanUpRunnable.INTERVAL, TestResultsCleanUpRunnable.INTERVAL, TimeUnit.MINUTES);
}
Aggregations