From 9eb876cdddf4d3ddf8f2518ece4e3fdaaac7339d Mon Sep 17 00:00:00 2001 From: MarkRx Date: Fri, 13 Feb 2026 11:18:25 -0700 Subject: [PATCH] Add additional debug logging to onNotifyCommit --- .../java/hudson/plugins/git/GitStatus.java | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/main/java/hudson/plugins/git/GitStatus.java b/src/main/java/hudson/plugins/git/GitStatus.java index 2d84994da1..8bab5aef70 100644 --- a/src/main/java/hudson/plugins/git/GitStatus.java +++ b/src/main/java/hudson/plugins/git/GitStatus.java @@ -360,6 +360,7 @@ public static class JenkinsAbstractProjectListener extends Listener { */ @Override public List onNotifyCommit(String origin, URIish uri, String sha1, List buildParameters, String... branches) { + long startMs = System.currentTimeMillis(); sha1 = cleanupSha1(sha1); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Received notification from {0} for uri = {1} ; sha1 = {2} ; branches = {3}", @@ -397,14 +398,30 @@ public List onNotifyCommit(String origin, URIish uri, Strin branchMatches = false; URIish matchedURL = null; for (URIish remoteURL : repository.getURIs()) { + if (LOGGER.isLoggable(Level.FINEST)) { + LOGGER.log(Level.FINEST, "Comparing notified uri {0} against repository uri {1} in project {2}", new Object[]{uri, remoteURL, project.getFullDisplayName()}); + } if (looselyMatches(uri, remoteURL)) { + if (LOGGER.isLoggable(Level.FINER)) { + LOGGER.log(Level.FINER, "Repository uri {0} matches notified uri {1} in project {2}", new Object[]{remoteURL, uri, project.getFullDisplayName()}); + } repositoryMatches = true; matchedURL = remoteURL; break; } } - if (!repositoryMatches || git.getExtensions().get(IgnoreNotifyCommit.class)!=null) { + if (!repositoryMatches) { + if (LOGGER.isLoggable(Level.FINER)) { + LOGGER.log(Level.FINER, "No matching repository uri for notified uri {0} in project {1}", new Object[]{uri, project.getFullDisplayName()}); + } + continue; + } + + if (git.getExtensions().get(IgnoreNotifyCommit.class)!=null) { + if (LOGGER.isLoggable(Level.FINER)) { + LOGGER.log(Level.FINER, "Ignoring notified uri {0} match in project {1} due to ignore notify commit setting", new Object[]{uri, project.getFullDisplayName()}); + } continue; } @@ -422,6 +439,9 @@ public List onNotifyCommit(String origin, URIish uri, Strin branchFound = true; } else { OUT: for (BranchSpec branchSpec : git.getBranches()) { + if (LOGGER.isLoggable(Level.FINEST)) { + LOGGER.log(Level.FINEST, "Comparing modified branches {0} against branch {1} in project {2}", new Object[]{Arrays.toString(branches), branchSpec.getName(), project.getFullDisplayName()}); + } if (branchSpec.getName().contains("$")) { // If the branchspec is parametrized, always run the polling if (LOGGER.isLoggable(Level.FINE)) { @@ -442,7 +462,12 @@ public List onNotifyCommit(String origin, URIish uri, Strin } } } - if (!branchFound) continue; + if (!branchFound) { + if (LOGGER.isLoggable(Level.FINER)) { + LOGGER.log(Level.FINER, "No matching branch spec for modified branches {0} in project {1}", new Object[]{Arrays.toString(branches), project.getFullDisplayName()}); + } + continue; + } urlFound = true; if (!(project instanceof ParameterizedJobMixIn.ParameterizedJob job && job.isDisabled())) { //JENKINS-30178 Add default parameters defined in the job @@ -499,6 +524,12 @@ public List onNotifyCommit(String origin, URIish uri, Strin } lastStaticBuildParameters = allBuildParameters; + + if (LOGGER.isLoggable(Level.FINER)) { + LOGGER.log(Level.FINER, "Processed notification from {0} for uri = {1} ; sha1 = {2} ; branches = {3} in {4} ms", + new Object[]{StringUtils.defaultIfBlank(origin, "?"), uri, sha1, Arrays.toString(branches), System.currentTimeMillis() - startMs}); + } + return result; } }