Skip to content

Commit

Permalink
Added logs to git plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
vwagh-dev committed Nov 25, 2024
1 parent 40c5aca commit 9aa4855
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/main/java/hudson/plugins/git/GitSCM.java
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ private PollingResult compareRemoteRevisionWithImpl(Job<?, ?> project, Launcher
// Poll for changes. Are there any unbuilt revisions that Jenkins ought to build ?

listener.getLogger().println("Using strategy: " + getBuildChooser().getDisplayName());

LOGGER.log(Level.FINEST, "Setting remote url: ");
final Run lastBuild = project.getLastBuild();
if (lastBuild == null) {
// If we've never been built before, well, gotta build!
Expand Down Expand Up @@ -924,6 +924,7 @@ private GitClient createClient(TaskListener listener, EnvVars environment, @NonN
listener.getLogger().println("No credentials specified");
} else {
String url = getParameterString(uc.getUrl(), environment);

StandardUsernameCredentials credentials = lookupScanCredentials(build, url, ucCredentialsId);
if (credentials != null) {
c.addCredentials(url, credentials);
Expand Down Expand Up @@ -984,18 +985,27 @@ private void fetchFrom(GitClient git,
for (URIish url : remoteRepository.getURIs()) {
try {
if (first) {
LOGGER.log(Level.FINEST, "Setting remote url: ", url.toPrivateASCIIString());
git.setRemoteUrl(remoteRepository.getName(), url.toPrivateASCIIString());
first = false;
} else {
LOGGER.log(Level.FINEST, "Adding remote url: ", url.toPrivateASCIIString());

Check warning on line 992 in src/main/java/hudson/plugins/git/GitSCM.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 992 is not covered by tests
git.addRemoteUrl(remoteRepository.getName(), url.toPrivateASCIIString());
}

FetchCommand fetch = git.fetch_().from(url, remoteRepository.getFetchRefSpecs());
FetchCommand fetch = git.fetch_();
if(fetch instanceof CliGitAPIImpl) {

Check warning on line 997 in src/main/java/hudson/plugins/git/GitSCM.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 997 is only partially covered, one branch is missing
LOGGER.log(Level.FINEST, "Instance of CliGitAPIImpl ");

Check warning on line 998 in src/main/java/hudson/plugins/git/GitSCM.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 998 is not covered by tests
} else {
LOGGER.log(Level.FINEST, "Instance of JGitAPIImpl ");
}
fetch.from(url, remoteRepository.getFetchRefSpecs());
for (GitSCMExtension extension : extensions) {
extension.decorateFetchCommand(this, run, git, listener, fetch);
}
fetch.execute();
} catch (GitException ex) {
ex.printStackTrace();

Check warning on line 1008 in src/main/java/hudson/plugins/git/GitSCM.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 1008 is not covered by tests
throw new GitException("Failed to fetch from "+url.toString(), ex);
}
}
Expand Down Expand Up @@ -1242,7 +1252,8 @@ private void retrieveChanges(Run build, GitClient git, TaskListener listener) th
} catch (GitException ex) {
/* Allow retry by throwing AbortException instead of
* GitException. See JENKINS-20531. */
ex.printStackTrace(listener.error("Error fetching remote repo '" + remoteRepository.getName() + "'"));
//ex.printStackTrace(listener.error("Error fetching remote repo '" + remoteRepository.getName() + "'"));
ex.printStackTrace();
throw new AbortException("Error fetching remote repo '" + remoteRepository.getName() + "'");
}
}
Expand Down

0 comments on commit 9aa4855

Please sign in to comment.