Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added logs #1219

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -590,12 +590,19 @@ public void execute() throws GitException, InterruptedException {
}

warnIfWindowsTemporaryDirNameHasSpaces();
LOGGER.log(Level.FINEST, "Printing available keys.... " );
credentials.entrySet().forEach(entry -> {
LOGGER.log(Level.FINEST, "credentials.key = " + entry.getKey() );
});

LOGGER.log(Level.FINEST, "Looking for key = " + url.toPrivateString() );
StandardCredentials cred = credentials.get(url.toPrivateString());
if (cred == null) {
LOGGER.log(Level.FINEST, "Credentials are null... Hence taking default credentials.." );
cred = defaultCredentials;
}
if (isAtLeastVersion(1, 8, 0, 0)) {
LOGGER.log(Level.FINEST, "Git version check is >= 1.8.0. Hence adding private ascii url i.e. " + url.toPrivateASCIIString());
addCheckedRemoteUrl(args, url.toPrivateASCIIString());
} else {
// CLI git 1.7.1 on CentOS 6 rejects URL encoded
Expand All @@ -616,7 +623,7 @@ public void execute() throws GitException, InterruptedException {
}
}
}

LOGGER.log(Level.FINEST, " Added remote url..." );
/* If url looks like a remote name reference, convert to remote URL for authentication */
/* See JENKINS-50573 for more details */
/* "git remote add" rejects remote names with ':' (and it is a common character in remote URLs) */
Expand Down Expand Up @@ -2103,6 +2110,7 @@ private String launchCommandWithCredentials(
}
}
try {

if (credentials instanceof SSHUserPrivateKey) {
SSHUserPrivateKey sshUser = (SSHUserPrivateKey) credentials;
listener.getLogger().println("using GIT_SSH to set credentials " + sshUser.getDescription());
Expand Down Expand Up @@ -2153,6 +2161,7 @@ private String launchCommandWithCredentials(
}

if ("http".equalsIgnoreCase(url.getScheme()) || "https".equalsIgnoreCase(url.getScheme())) {
LOGGER.log(Level.FINEST, " URL scheme is http or https" );
if (proxy != null) {
boolean shouldProxy = true;
for (Pattern p : proxy.getNoProxyHostPatterns()) {
Expand All @@ -2161,6 +2170,7 @@ private String launchCommandWithCredentials(
break;
}
}
LOGGER.log(Level.FINEST, " Is proxy : " + shouldProxy );
if (shouldProxy) {
env = new EnvVars(env);
listener.getLogger().println("Setting http proxy: " + proxy.name + ":" + proxy.port);
Expand Down Expand Up @@ -2786,20 +2796,30 @@ private String launchCommandIn(ArgumentListBuilder args, File workDir, EnvVars e
freshEnv.put("GIT_ASKPASS", "echo");
}
/* Prepend extra git command line arguments if any */
if(extraGitCommandArguments != null)
LOGGER.log(Level.FINEST, "Extra git CLI args : " + extraGitCommandArguments);

if (!extraGitCommandArguments.isEmpty()) {
args = args.prepend(extraGitCommandArguments.toArray(new String[0]));
}

LOGGER.log(Level.FINEST, "Enriched args1: " + args);

String command = gitExe + " " + StringUtils.join(args.toCommandArray(), " ");
try {
args.prepend(gitExe);
LOGGER.log(Level.FINEST, "Enriched args2: " + args);
if (CALL_SETSID && launcher.isUnix() && env.containsKey("GIT_SSH") && env.containsKey("DISPLAY")) {
/* Detach from controlling terminal for git calls with ssh authentication */
/* GIT_SSH won't call the passphrase prompt script unless detached from controlling terminal */
args.prepend("setsid");
}
LOGGER.log(Level.FINEST, "Enriched args3: " + args);
int usedTimeout = timeout == null ? TIMEOUT : timeout;
listener.getLogger().println(" > " + command + TIMEOUT_LOG_PREFIX + usedTimeout);


LOGGER.log(Level.FINEST, "Command ==> : " + command +", env ==> "+ freshEnv + ", workDir ==> "+ workDir + ", timeout ==> "+ usedTimeout +" minutes");
Launcher.ProcStarter p =
launcher.launch().cmds(args.toCommandArray()).envs(freshEnv);

Expand Down Expand Up @@ -2842,9 +2862,11 @@ private String launchCommandIn(ArgumentListBuilder args, File workDir, EnvVars e
throw new GitException("Command \"" + command + "\" returned status code " + status + ":\nstdout: "
+ stdout + "\nstderr: " + stderr);
}

LOGGER.log(Level.FINEST, "Process Status ==> : " + status);
return stdout;
} catch (GitException | InterruptedException e) {
LOGGER.log(Level.FINEST, "Error performing git command (GitException | InterruptedException): " + command, e);
e.printStackTrace();
if (e.getMessage().contains("unsupported option \"accept-new\"")) {
listener.getLogger()
.println(
Expand All @@ -2854,6 +2876,8 @@ private String launchCommandIn(ArgumentListBuilder args, File workDir, EnvVars e
}
throw e;
} catch (Throwable e) {
LOGGER.log(Level.FINEST, "Error performing git command (Throwable): " + command, e);
e.printStackTrace();
reportFailureClues();
throw new GitException("Error performing git command: " + command, e);
}
Expand Down