Skip to content

Commit e2de9aa

Browse files
authored
[JENKINS-60304] Forward GitLabApiException as IOException (#88)
Forward GitLabApiException as IOException to inform SCM API about failures in eg retrieve methods. Otherwise unreachable/failed gitlab server calls are interpreted as 'empty' repositories, therfore all branches gets removed.
1 parent 77ccda4 commit e2de9aa

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

src/main/java/io/jenkins/plugins/gitlabbranchsource/GitLabSCMFileSystem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public long lastModified() throws IOException {
5353
try {
5454
return gitLabApi.getCommitsApi().getCommit(projectPath, ref).getCommittedDate().getTime();
5555
} catch (GitLabApiException e) {
56-
return 0;
56+
throw new IOException("Failed to retrieve last modified time", e);
5757
}
5858
}
5959

src/main/java/io/jenkins/plugins/gitlabbranchsource/GitLabSCMNavigator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ public void visitSources(@NonNull final SCMSourceObserver observer)
302302
observer.getListener().getLogger().format("%n%d projects were processed%n", count);
303303
} catch (GitLabApiException e) {
304304
LOGGER.log(Level.WARNING, "Exception caught:" + e, e);
305+
throw new IOException("Failed to visit SCM source", e);
305306
}
306307
}
307308

src/main/java/io/jenkins/plugins/gitlabbranchsource/GitLabSCMSource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ protected SCMRevision retrieve(@NonNull SCMHead head, @NonNull TaskListener list
294294
}
295295
} catch (GitLabApiException e) {
296296
LOGGER.log(Level.WARNING, "Exception caught:" + e, e);
297+
throw new IOException("Failed to retrieve the SCM revision for " + head.getName(), e);
297298
}
298-
return super.retrieve(head, listener);
299299
}
300300

301301
@Override
@@ -528,6 +528,7 @@ public SCMSourceCriteria.Probe create(
528528
}
529529
} catch (GitLabApiException e) {
530530
LOGGER.log(Level.WARNING, "Exception caught:" + e, e);
531+
throw new IOException("Failed to fetch latest heads", e);
531532
} finally {
532533
SCMSourceOwner owner = this.getOwner();
533534
if (owner != null) {

0 commit comments

Comments
 (0)