/** {@inheritDoc} */ @Deprecated public boolean hasGitModules(String treeIsh) throws GitException { try { return new File(workspace, ".gitmodules").exists(); } catch (SecurityException ex) { throw new GitException( "Security error when trying to check for .gitmodules. Are you sure you have correct permissions?", ex); } catch (Exception e) { throw new GitException("Couldn't check for .gitmodules", e); } }
throw new GitException("Impossible to create sparse checkout dir " + sparseCheckoutDir.getAbsolutePath()); throw new GitException("Could not write sparse checkout file " + sparseCheckoutFile.getAbsolutePath(), ex); if(ge.getMessage().contains(normalReturnCode)) { listener.getLogger().println(ge.getMessage()); } else { throw ge;
public ObjectId mergeBase(ObjectId id1, ObjectId id2) { try { String result; try { result = launchCommand("merge-base", id1.name(), id2.name()); } catch (GitException ge) { ge.printStackTrace(); return null; } BufferedReader rdr = new BufferedReader(new StringReader(result)); String line; while ((line = rdr.readLine()) != null) { // Add the SHA1 return ObjectId.fromString(line); } } catch (Exception e) { throw new GitException("Error parsing merge base", e); } return null; }
throw new GitException("Could not fetch from any repository"); break; } catch (GitException ex) { listener.error("Error cloning remote repo '%s' : %s", rc.getName(), ex.getMessage()); if (ex.getCause() != null) { listener.error("Cause: %s", ex.getCause().getMessage()); throw new GitException("Could not clone"); throw new GitException("Could not fetch from any repository");
@Override protected void perform(final TaskListener listener) throws Exception { final EnvVars environment = getRun().getEnvironment(listener); final FilePath workspace = new FilePath(new File(ws)); final GitClient git = Git.with(listener, environment) .in(workspace) .getClient(); for (Map.Entry<String, String> entry : tagSet.entrySet()) { try { String buildNum = "jenkins-" + getRun().getParent().getName().replace(" ", "_") + "-" + entry.getValue(); git.tag(entry.getValue(), "Jenkins Build #" + buildNum); for (Map.Entry<String, String> e : tagSet.entrySet()) GitTagAction.this.tags.get(e.getKey()).add(e.getValue()); getRun().save(); workerThread = null; } catch (GitException ex) { ex.printStackTrace(listener.error("Error tagging repo '%s' : %s", entry.getKey(), ex.getMessage())); // Failed. Try the next one listener.getLogger().println("Trying next branch"); } } } }
private Map<String, BlameResult> loadBlameResultsForFiles(final Map<String, BlameRequest> linesOfConflictingFiles) throws InterruptedException, IOException { try { ObjectId headCommit = git.revParse(gitCommit); return git.withRepository(new BlameCallback(this, headCommit, linesOfConflictingFiles.values())); } catch (GitException exception) { log("Can't determine head commit using 'git rev-parse'. Skipping blame. %n%s%n", exception.getMessage()); return Collections.emptyMap(); } }
return; } catch (Exception e) { throw new GitException("Could determine remote.origin.url", e); listener.getLogger().println(ex.getLocalizedMessage());
/** * Fetch information from a particular remote repository. * * @param git * @param listener * @param remoteRepository * @return true if fetch goes through, false otherwise. * @throws */ private boolean fetchFrom(IGitAPI git, TaskListener listener, RemoteConfig remoteRepository) { try { git.fetch(remoteRepository); return true; } catch (GitException ex) { ex.printStackTrace(listener.error( "Problem fetching from " + remoteRepository.getName() + " / " + remoteRepository.getName() + " - could be unavailable. Continuing anyway")); } return false; }
@Override public SCMRevision run(GitClient client, String remoteName) throws IOException, InterruptedException { String hash; try { hash = client.revParse(revision).name(); } catch (GitException x) { // Try prepending remote name in case it was a branch. try { hash = client.revParse(context.remoteName() + "/" + revision).name(); } catch (GitException x2) { listener.getLogger().println(x.getMessage()); listener.getLogger().println(x2.getMessage()); return null; } } return new SCMRevisionImpl(new SCMHead(revision), hash); } },
ex.printStackTrace(listener.error("Error cloning remote repo '" + rc.getName() + "'")); throw new AbortException("Error cloning remote repo '" + rc.getName() + "'"); ex.printStackTrace(listener.error("Error fetching remote repo '" + remoteRepository.getName() + "'")); throw new AbortException("Error fetching remote repo '" + remoteRepository.getName() + "'");
public void tag(String tagName, String comment) throws GitException { tagName = tagName.replace(' ', '_'); try { launchCommand("tag", "-a", "-f", "-m", comment, tagName); } catch (GitException e) { throw new GitException("Could not apply tag " + tagName, e); } }
launchCommandWithCredentials(lfsArgs, workspace, cred, new URIish(url), timeout); } catch (URISyntaxException e) { throw new GitException("Invalid URL " + url, e); if (Pattern.compile("index\\.lock").matcher(e.getMessage()).find()) { throw new GitLockFailedException("Could not lock repository. Please try again", e); } else { if (branch != null) throw new GitException("Could not checkout " + branch + " with start point " + ref, e); else throw new GitException("Could not checkout " + ref, e); FileUtils.forceDelete(indexFile); } catch (IOException ioe) { throw new GitException( "Could not remove index lock file on interrupting thread", ioe);
throw new GitException("Could not fetch from any repository"); break; } catch (GitException ex) { ex.printStackTrace(listener.error("Error cloning remote repo '%s' ", rc.getName())); throw new GitException("Could not clone repository"); throw new GitException("Could not fetch from any repository");
/** * Fetch information from a particular remote repository. * * @param git * @param listener * @param remoteRepository * @return true if fetch goes through, false otherwise. * @throws */ private boolean fetchFrom(IGitAPI git, TaskListener listener, RemoteConfig remoteRepository) { try { git.fetch(remoteRepository); return true; } catch (GitException ex) { listener.error( "Problem fetching from " + remoteRepository.getName() + " / " + remoteRepository.getName() + " - could be unavailable. Continuing anyway"); listener.error(" (Underlying report) : " + ex.getMessage()); } return false; }
e.printStackTrace(listener.error("Failed to determine if we want to exclude " + r.getSha1String())); return false; // for historical reason this is not considered a fatal error.
public void commit(File f) throws GitException { try { launchCommand("commit", "-F", f.getAbsolutePath()); } catch (GitException e) { throw new GitException("Cannot commit " + f, e); } }
git.getHeadRev(url, "HEAD"); } catch (GitException e) { return FormValidation.error(Messages.UserRemoteConfig_FailedToConnect(e.getMessage()));
ex.printStackTrace(listener.error( "Problem fetching submodules from a path relative to " + remoteRepository.getName()
/** {@inheritDoc} */ public void tag(String tagName, String comment) throws GitException, InterruptedException { tagName = tagName.replace(' ', '_'); try { launchCommand("tag", "-a", "-f", "-m", comment, tagName); } catch (GitException e) { throw new GitException("Could not apply tag " + tagName, e); } }
printCommitMessageToLog(listener, git, revToBuild); } catch (GitException ge) { listener.getLogger().println("Exception logging commit message for " + revToBuild + ": " + ge.getMessage());