use of hudson.util.LogTaskListener in project blueocean-plugin by jenkinsci.
the class GitCloneReadSaveRequest method cloneRepo.
GitClient cloneRepo() throws InterruptedException, IOException {
EnvVars environment = new EnvVars();
TaskListener taskListener = new LogTaskListener(Logger.getAnonymousLogger(), Level.ALL);
String gitExe = gitTool.getGitExe();
GitClient git = Git.with(taskListener, environment).in(repositoryPath).using(gitExe).getClient();
git.addCredentials(gitSource.getRemote(), getCredential());
try {
git.clone(gitSource.getRemote(), "origin", true, null);
log.fine("Repository " + gitSource.getRemote() + " cloned to: " + repositoryPath.getCanonicalPath());
} catch (GitException e) {
// check if this is an empty repository
boolean isEmptyRepo = false;
try {
if (git.getRemoteReferences(gitSource.getRemote(), null, true, false).isEmpty()) {
isEmptyRepo = true;
}
} catch (GitException ge) {
// *sigh* @ this necessary hack; {@link org.jenkinsci.plugins.gitclient.CliGitAPIImpl#getRemoteReferences}
if ("unexpected ls-remote output ".equals(ge.getMessage())) {
// blank line, command succeeded
isEmptyRepo = true;
}
// ignore other reasons
}
if (isEmptyRepo) {
git.init();
git.addRemoteUrl("origin", gitSource.getRemote());
log.fine("Repository " + gitSource.getRemote() + " not found, created new to: " + repositoryPath.getCanonicalPath());
} else {
throw e;
}
}
return git;
}
use of hudson.util.LogTaskListener in project workflow-cps-plugin by jenkinsci.
the class EnvActionImpl method getEnvironment.
@Override
public EnvVars getEnvironment() throws IOException, InterruptedException {
TaskListener listener;
if (owner instanceof FlowExecutionOwner.Executable) {
FlowExecutionOwner executionOwner = ((FlowExecutionOwner.Executable) owner).asFlowExecutionOwner();
if (executionOwner != null) {
listener = executionOwner.getListener();
} else {
listener = new LogTaskListener(LOGGER, Level.INFO);
}
} else {
listener = new LogTaskListener(LOGGER, Level.INFO);
}
EnvVars e = owner.getEnvironment(listener);
e.putAll(env);
return e;
}
Aggregations