Skip to content

Commit

Permalink
Merge pull request #815 from jenkinsci/error-handling-missing-commit
Browse files Browse the repository at this point in the history
[JENKINS-73297] Improve error handling when commit is not found
  • Loading branch information
uhafner authored Sep 10, 2024
2 parents d0e02e1 + beeb13f commit c8878a7
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ private RemoteResultWrapper<Delta> calculateDelta(final Repository repository) t
GitDelta delta = new GitDelta(currentCommitId, referenceCommitId, Map.of(), exception.getMessage());
RemoteResultWrapper<Delta> wrapper = new RemoteResultWrapper<>(delta, "Errors from Git Delta:");

wrapper.logError("Could not find commit", exception);
wrapper.logException(exception, "Could not find the specified commit - is the SCM parameter correctly set?");

return wrapper;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public Optional<Delta> calculateDelta(final Run<?, ?> build, final Run<?, ?> ref
RemoteResultWrapper<Delta> wrapped = git.withRepository(
new DeltaRepositoryCallback(currentCommit, referenceCommit));
wrapped.getInfoMessages().forEach(log::logInfo);
wrapped.getErrorMessages().forEach(log::logError);
return Optional.of(wrapped.getResult());
}
catch (IOException | InterruptedException exception) {
Expand All @@ -77,12 +78,12 @@ public Optional<Delta> calculateDelta(final Run<?, ?> build, final Run<?, ?> ref
}

/**
* Returns the latest commit of the {@link GitCommitsRecord commits record} of a Git repository.
* Returns the latest commit of the {@link GitCommitsRecord commit record} of a Git repository.
*
* @param buildName
* the name of the build the commits record corresponds to
* @param record
* the commits record
* the commit record
* @param log
* the log
*
Expand Down
Loading

0 comments on commit c8878a7

Please sign in to comment.