org.eclipse.jgit.api.Git Java Examples
The following examples show how to use
org.eclipse.jgit.api.Git.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GitUtils.java From gitPic with MIT License | 8 votes |
public static void pull(Repository repository) { Git git = new Git(repository); try { PullResult result = git.pull().call(); FetchResult fetchResult = result.getFetchResult(); MergeResult mergeResult = result.getMergeResult(); if (fetchResult.getMessages() != null && !fetchResult.getMessages().isEmpty()) { logger.info(fetchResult.getMessages()); } logger.info(mergeResult.getMergeStatus().toString()); if (!mergeResult.getMergeStatus().isSuccessful()) { throw new TipException(mergeResult.getMergeStatus().toString()); } } catch (GitAPIException e) { logger.error(e.getMessage(), e); throw new TipException("git commit 异常"); } }
Example #2
Source File: BlameCalculator.java From diff-check with GNU Lesser General Public License v2.1 | 6 votes |
public List<BlameResult> calculate( File repoDir, List<String> filePathList, String startRev) throws Exception { try (Git git = Git.open(repoDir); ObjectReader reader = git.getRepository().newObjectReader(); RevWalk rw = new RevWalk(git.getRepository())) { RevCommit startCommit = rw.parseCommit(git.getRepository().resolve(startRev)); List<BlameResult> resultList = new ArrayList<>(); for (String filePath : filePathList) { BlameResult result = calculateBlame(filePath, startCommit, git); resultList.add(result); } return resultList; } }
Example #3
Source File: GitManagerTest.java From WebIDE-Backend with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testForCreateAnotationTag() throws GitAPIException, IOException { Git git = Git.wrap(repository); gitMgr.createTag(ws, "test", null, "test message", false); List<Ref> refs = git.tagList().call(); assertEquals(1, refs.size()); assertEquals("refs/tags/test", refs.get(0).getName()); assertNotEquals(repository.resolve("HEAD"), refs.get(0).getObjectId()); RevWalk walk = new RevWalk(repository); RevTag tag = walk.parseTag(refs.get(0).getObjectId()); assertEquals("test message", tag.getFullMessage()); }
Example #4
Source File: RepositoryResource.java From fabric8-forge with Apache License 2.0 | 6 votes |
protected void checkoutBranch(Git git, GitContext context) throws GitAPIException { String current = currentBranch(git); if (Objects.equals(current, branch)) { return; } System.out.println("Checking out branch: " + branch); // lets check if the branch exists CheckoutCommand command = git.checkout().setName(branch); boolean exists = localBranchExists(git, branch); if (!exists) { command = command.setCreateBranch(true).setForce(true). setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK). setStartPoint(getRemote() + "/" + branch); } Ref ref = command.call(); if (LOG.isDebugEnabled()) { LOG.debug("Checked out branch " + branch + " with results " + ref.getName()); } configureBranch(git, branch); }
Example #5
Source File: AbstractUpgradeOperation.java From studio with GNU General Public License v3.0 | 6 votes |
protected void commitAllChanges(String site) throws UpgradeException { try { Path repositoryPath = getRepositoryPath(site); FileRepositoryBuilder builder = new FileRepositoryBuilder(); Repository repo = builder .setGitDir(repositoryPath.toFile()) .readEnvironment() .findGitDir() .build(); try (Git git = new Git(repo)) { git.add().addFilepattern(".").call(); Status status = git.status().call(); if (status.hasUncommittedChanges() || !status.isClean()) { git.commit() .setAll(true) .setMessage(getCommitMessage()) .call(); } } } catch (IOException | GitAPIException e) { throw new UpgradeException("Error committing changes for site " + site, e); } }
Example #6
Source File: GitManagerTest.java From WebIDE-Backend with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void initRepo(Repository repository) throws IOException, GitAPIException { Git git = new Git(repository); ws.write("README.md", "This is readme", false, true, false); ws.write("README2.md", "this is readme2", false, true, false); git.add().addFilepattern("README.md").call(); git.add().addFilepattern("README2.md").call(); git.commit().setMessage("create readme").call(); // create test branch createTestBranch(repository, "branch1", (g, branch) -> { ws.write("README.md", "branch1", false, true, false); g.add().addFilepattern("README.md").call(); g.commit().setMessage(branch).call(); }); createTestBranch(repository, "branch2", (g, branch) -> { ws.write("README.md", "branch2", false, true, false); g.add().addFilepattern("README.md").call(); g.commit().setMessage(branch).call(); }); }
Example #7
Source File: GitClient.java From cf-butler with Apache License 2.0 | 6 votes |
public RevCommit getLatestCommit(Repository repo) throws IOException, GitAPIException { RevCommit latestCommit = null; int inc = 0; try( Git git = new Git(repo); RevWalk walk = new RevWalk(repo); ) { List<Ref> branches = git.branchList().call(); for(Ref branch : branches) { RevCommit commit = walk.parseCommit(branch.getObjectId()); if (inc == 0) latestCommit = commit; if(commit.getAuthorIdent().getWhen().compareTo(latestCommit.getAuthorIdent().getWhen()) > 0) latestCommit = commit; inc++; } } return latestCommit; }
Example #8
Source File: AppRepo.java From app-runner with MIT License | 6 votes |
public static AppRepo create(String name, String sampleAppName) { try { File originDir = copySampleAppToTempDir(sampleAppName); InitCommand initCommand = Git.init(); initCommand.setDirectory(originDir); Git origin = initCommand.call(); origin.add().addFilepattern(".").call(); origin.commit().setMessage("Initial commit") .setAuthor(new PersonIdent("Author Test", "[email protected]")) .call(); return new AppRepo(name, originDir, origin); } catch (Exception e) { throw new RuntimeException("Error while creating git repo", e); } }
Example #9
Source File: JGitEnvironmentRepository.java From spring-cloud-config with Apache License 2.0 | 6 votes |
private Ref resetHard(Git git, String label, String ref) { ResetCommand reset = git.reset(); reset.setRef(ref); reset.setMode(ResetType.HARD); try { Ref resetRef = reset.call(); if (resetRef != null) { this.logger.info( "Reset label " + label + " to version " + resetRef.getObjectId()); } return resetRef; } catch (Exception ex) { String message = "Could not reset to remote for " + label + " (current ref=" + ref + "), remote: " + git.getRepository().getConfig() .getString("remote", "origin", "url"); warn(message, ex); return null; } }
Example #10
Source File: JenkinsCloneRepository.java From repairnator with MIT License | 6 votes |
@Override protected StepStatus businessExecute() { String repoSlug = this.gitSlug; String repoRemotePath = this.gitUrl; String repoLocalPath = this.getInspector().getRepoLocalPath(); String repoBranch = this.gitBranch; String gitCommitHash = this.gitCommitHash; try { Git git = Git.cloneRepository().setCloneSubmodules(true).setURI(repoRemotePath).setBranch(repoBranch).setDirectory(new File(repoLocalPath)).call(); /* Also check out if provided gitCommitHash if provided */ if (gitCommitHash != null){ git.checkout().setName(gitCommitHash).call(); } return StepStatus.buildSuccess(this); } catch (Exception e) { this.addStepError("Repository " + repoSlug + " cannot be cloned.", e); return StepStatus.buildError(this, PipelineState.NOTCLONABLE); } }
Example #11
Source File: GitUtils.java From singleton with Eclipse Public License 2.0 | 6 votes |
public static File cloneRepository(String remoteUri, String tempFolder, String branch, CredentialsProvider credentialsProvider) { File file = new File(tempFolder); try { if (file.exists()) { deleteFolder(file); } file.mkdirs(); Git.cloneRepository().setURI(remoteUri).setDirectory(file).setBranch(branch) .setCredentialsProvider(credentialsProvider).call(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); logger.error(e.getMessage(), e); } return file; }
Example #12
Source File: SvnTestServer.java From git-as-svn with GNU General Public License v2.0 | 6 votes |
private void cleanupBranches(@NotNull Repository repository) throws IOException { final List<String> branches = new ArrayList<>(); for (Ref ref : repository.getRefDatabase().getRefsByPrefix(Constants.R_HEADS + TEST_BRANCH_PREFIX)) { branches.add(ref.getName().substring(Constants.R_HEADS.length())); } if (!branches.isEmpty()) { for (String branch : branches) { log.info("Cleanup branch: {}", branch); try { new Git(repository) .branchDelete() .setBranchNames(branch) .setForce(true) .call(); } catch (GitAPIException e) { log.error("Cleanup branch: " + branch, e); } } } }
Example #13
Source File: UpdaterGenerator.java From neembuu-uploader with GNU General Public License v3.0 | 6 votes |
/** * Clone GIT repository from sourceforge. * * @param gitDirectory The directory of Git. */ private void gitClone(File gitDirectory) { try { git = Git.cloneRepository() .setDirectory(gitDirectory) .setURI(env.gitURI()) //.setURI("http://git.code.sf.net/p/neembuuuploader/gitcode") .setProgressMonitor(new TextProgressMonitor()).call(); for (Ref f : git.branchList().setListMode(ListBranchCommand.ListMode.ALL).call()) { git.checkout().setName(f.getName()).call(); System.out.println("checked out branch " + f.getName() + ". HEAD: " + git.getRepository().getRef("HEAD")); } // try to checkout branches by specifying abbreviated names git.checkout().setName("master").call(); } catch (GitAPIException | IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } }
Example #14
Source File: RepositoryManagementServiceInternalImpl.java From studio with GNU General Public License v3.0 | 6 votes |
@Override public RepositoryStatus getRepositoryStatus(String siteId) throws CryptoException, ServiceLayerException { GitRepositoryHelper helper = GitRepositoryHelper.getHelper(studioConfiguration); Repository repo = helper.getRepository(siteId, SANDBOX); RepositoryStatus repositoryStatus = new RepositoryStatus(); logger.debug("Execute git status and return conflicting paths and uncommitted changes"); try (Git git = new Git(repo)) { Status status = git.status().call(); repositoryStatus.setClean(status.isClean()); repositoryStatus.setConflicting(status.getConflicting()); repositoryStatus.setUncommittedChanges(status.getUncommittedChanges()); } catch (GitAPIException e) { logger.error("Error while getting repository status for site " + siteId, e); throw new ServiceLayerException("Error getting repository status for site " + siteId, e); } return repositoryStatus; }
Example #15
Source File: GitContentRepository.java From studio with GNU General Public License v3.0 | 6 votes |
@Override public void resetStagingRepository(String siteId) throws ServiceLayerException { Repository repo = helper.getRepository(siteId, PUBLISHED); String stagingName = servicesConfig.getStagingEnvironment(siteId); String liveName = servicesConfig.getLiveEnvironment(siteId); synchronized (repo) { try (Git git = new Git(repo)) { logger.debug("Checkout live first becuase it is not allowed to delete checkedout branch"); git.checkout().setName(liveName).call(); logger.debug("Delete staging branch in order to reset it for site: " + siteId); git.branchDelete().setBranchNames(stagingName).setForce(true).call(); logger.debug("Create new branch for staging with live HEAD as starting point"); git.branchCreate() .setName(stagingName) .setStartPoint(liveName) .call(); } catch (GitAPIException e) { logger.error("Error while reseting staging environment for site: " + siteId); throw new ServiceLayerException(e); } } }
Example #16
Source File: CurioGenericCiPluginTest.java From curiostack with MIT License | 6 votes |
private static void addDiffs(Path projectDir, Git git, String... paths) throws Exception { for (String path : paths) { var filePath = projectDir.resolve(path); try { Files.writeString(filePath, Files.readString(filePath).replace("|DIFF-ME|", "-DIFFED-")); } catch (IOException e) { throw new UncheckedIOException("Could not add diff to file.", e); } } git.commit() .setAll(true) .setMessage("Automated commit in test") .setAuthor("Unit Test", "[email protected]") .call(); }
Example #17
Source File: AbstractTest.java From git-code-format-maven-plugin with MIT License | 5 votes |
@Before public final void before() throws Exception { projectRoot = resources.getBasedir(projectRootDirectoryName).toPath(); gitCLI = new GitCLI(projectRoot); jGit = Git.init().setDirectory(projectRoot.toFile()).call(); jGit.add().addFilepattern(".").call(); jGit.commit().setAll(true).setMessage("First commit").call(); projectDestination = Files.createDirectories(Paths.get("target/test-projects")) .resolve(projectRoot.getParent().relativize(projectRoot)); if (Files.notExists(projectDestination)) { return; } Files.walk(projectDestination, FileVisitOption.FOLLOW_LINKS) .sorted(Comparator.reverseOrder()) .forEach( path -> { try { Files.deleteIfExists(path); } catch (IOException e) { throw new RuntimeException(e); } }); Files.deleteIfExists(projectDestination); }
Example #18
Source File: GitManagerTest.java From WebIDE-Backend with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testBlameNotTracked() throws IOException, GitAPIException { try (Git git = Git.wrap(repository)) { writeTrashFile("testBlame", "first line\n1"); List<GitBlame> gitBlames = gitMgr.blame(ws, "testBlame"); assertEquals(2, gitBlames.size()); assertNull(gitBlames.get(0).getShortName()); assertNull(gitBlames.get(1).getShortName()); } }
Example #19
Source File: GitRepositoryExampleService.java From statecharts with Eclipse Public License 1.0 | 5 votes |
private boolean doesBranchExist(Git git, BranchType type, String remoteBranch) throws GitAPIException { if (type == GitRepositoryExampleService.BranchType.LOCAL) { return git.branchList().setListMode(ListMode.ALL).call().stream() .anyMatch(branch -> branch.getName().equals("refs/heads/" + remoteBranch)); } else { return git.branchList().setListMode(ListMode.REMOTE).call().stream() .anyMatch(branch -> branch.getName().equals("refs/remotes/origin/" + remoteBranch)); } }
Example #20
Source File: MergeBaseCalculatorTest.java From diff-check with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testCalculateMergeBase() throws Exception { try (Git git = new Git(db); ObjectReader reader = git.getRepository().newObjectReader()) { File repoDir = git.getRepository().getDirectory().getParentFile(); File file = new File(repoDir, "file.txt"); writeStringToFile(file, "hello\n"); git.add() .addFilepattern(file.getName()) .call(); RevCommit baseCommit = doCommit(git); writeStringToFile(file, "hello world\n"); git.add() .addFilepattern(file.getName()) .call(); RevCommit commit1 = doCommit(git); git.reset().setMode(ResetType.HARD).setRef(baseCommit.name()).call(); writeStringToFile(file, "hello code\n"); git.add() .addFilepattern(file.getName()) .call(); RevCommit commit2 = doCommit(git); String mergeBase = new MergeBaseCalculator() .calculateMergeBase(repoDir, commit1.name(), commit2.name()); Assert.assertEquals(baseCommit.name(), mergeBase); } }
Example #21
Source File: RepositoryResource.java From fabric8-forge with Apache License 2.0 | 5 votes |
@GET @Path("commitDetail/{commitId}") public CommitDetail commitDetail(final @PathParam("commitId") String commitId) throws Exception { return gitReadOperation(new GitOperation<CommitDetail>() { @Override public CommitDetail call(Git git, GitContext context) throws Exception { return doCommitDetail(git, commitId); } }); }
Example #22
Source File: DiffCalculatorTest.java From diff-check with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testDoCalculateIndexedDiffWhenFileAdded() throws Exception { try (Git git = new Git(db); ObjectReader reader = git.getRepository().newObjectReader()) { File repoDir = git.getRepository().getDirectory().getParentFile(); File fileToAdd = new File(repoDir, "added.txt"); File fileRemainUnchanged = new File(repoDir, "unchanged.txt"); writeStringToFile(fileRemainUnchanged, "no change"); git.add() .addFilepattern(fileRemainUnchanged.getName()) .call(); RevCommit oldCommit = doCommit(git); writeStringToFile(fileToAdd, "add file"); git.add().addFilepattern(fileToAdd.getName()).call(); DiffCalculator calculator = DiffCalculator.builder() .diffAlgorithm(new HistogramDiff()) .build(); List<DiffEntryWrapper> wrappers = Whitebox.<List<DiffEntryWrapper>>invokeMethod( calculator, "doCalculateIndexedDiff", oldCommit, reader, git, repoDir); Assert.assertEquals(1, wrappers.size()); DiffEntryWrapper wrapper = wrappers.get(0); Assert.assertEquals(fileToAdd, wrapper.getNewFile()); List<Edit> edits = wrapper.getEditList(); Edit insertEdit = edits.get(0); Assert.assertEquals(Edit.Type.INSERT, insertEdit.getType()); Assert.assertEquals(0, insertEdit.getBeginB()); Assert.assertEquals(1, insertEdit.getEndB()); } }
Example #23
Source File: GitVersioningExtensionIT.java From maven-git-versioning-extension with MIT License | 5 votes |
@Test void tagVersioning_cliOption_conflictingTag() throws Exception { // Given Git git = Git.init().setDirectory(projectDir.toFile()).call(); RevCommit givenCommit = git.commit().setMessage("initial commit").setAllowEmpty(true).call(); String givenTag = "v1"; git.tag().setAnnotated(false).setName("v2").call(); writeModel(projectDir.resolve("pom.xml").toFile(), pomModel); writeExtensionsFile(projectDir); Configuration extensionConfig = new Configuration(); extensionConfig.tag.add(createTagVersionDescription()); writeExtensionConfigFile(projectDir, extensionConfig); // When Verifier verifier = new Verifier(projectDir.toFile().getAbsolutePath()); verifier.addCliOption("-Dgit.tag=" + givenTag); verifier.executeGoal("verify"); // Then String log = getLog(verifier); assertThat(log).doesNotContain("[ERROR]", "[FATAL]"); String expectedVersion = givenTag + "-gitVersioning"; assertThat(log).contains("Building " + pomModel.getArtifactId() + " " + expectedVersion); Model gitVersionedPomModel = readModel(projectDir.resolve("target/").resolve(GIT_VERSIONING_POM_NAME).toFile()); assertThat(gitVersionedPomModel).satisfies(it -> assertSoftly(softly -> { softly.assertThat(it.getModelVersion()).isEqualTo(pomModel.getModelVersion()); softly.assertThat(it.getGroupId()).isEqualTo(pomModel.getGroupId()); softly.assertThat(it.getArtifactId()).isEqualTo(pomModel.getArtifactId()); softly.assertThat(it.getVersion()).isEqualTo(expectedVersion); softly.assertThat(it.getProperties()).doesNotContainKeys( "git.commit", "git.ref", "git.tag" ); })); }
Example #24
Source File: RepositoryResource.java From fabric8-forge with Apache License 2.0 | 5 votes |
protected CommitInfo doWrite(Git git, String path, byte[] contents, PersonIdent personIdent, String commitMessage) throws Exception { File file = getRelativeFile(path); file.getParentFile().mkdirs(); Files.writeToFile(file, contents); String filePattern = getFilePattern(path); AddCommand add = git.add().addFilepattern(filePattern).addFilepattern("."); add.call(); CommitCommand commit = git.commit().setAll(true).setAuthor(personIdent).setMessage(commitMessage); RevCommit revCommit = commitThenPush(git, commit); return createCommitInfo(revCommit); }
Example #25
Source File: SiteRepositoryUpgradePipelineImpl.java From studio with GNU General Public License v3.0 | 5 votes |
protected void mergeTemporaryBranch(Repository repository, Git git) throws IOException, GitAPIException { logger.debug("Merging changes from upgrade branch"); git.merge() .include(repository.findRef(siteUpgradeBranch)) .setMessage(commitMessage) .setCommit(true) .call(); }
Example #26
Source File: GitRepositoryTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
protected List<String> listUntracked(Repository repository) throws IOException, GitAPIException { List<String> result = new ArrayList<>(); result.add("Untracked:"); try (Git git = new Git(repository)) { Status status = git.status().call(); result.addAll(status.getUntrackedFolders()); result.addAll(status.getUntracked()); return result; } }
Example #27
Source File: GitUtil.java From Jpom with MIT License | 5 votes |
/** * 拉取对应分支最新代码 * * @param url 远程url * @param file 仓库路径 * @param branchName 分支名 * @param credentialsProvider 凭证 * @throws IOException IO * @throws GitAPIException api */ public static void checkoutPull(String url, File file, String branchName, CredentialsProvider credentialsProvider) throws IOException, GitAPIException { try (Git git = initGit(url, file, credentialsProvider)) { // 判断本地是否存在对应分支 List<Ref> list = git.branchList().setListMode(ListBranchCommand.ListMode.ALL).call(); boolean createBranch = true; for (Ref ref : list) { String name = ref.getName(); if (name.startsWith(Constants.R_HEADS + branchName)) { createBranch = false; break; } } // 切换分支 if (!StrUtil.equals(git.getRepository().getBranch(), branchName)) { git.checkout(). setCreateBranch(createBranch). setName(branchName). setForceRefUpdate(true). setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM). call(); } git.pull().setCredentialsProvider(credentialsProvider).call(); } catch (TransportException t) { checkTransportException(t); throw t; } }
Example #28
Source File: GitManagerTest.java From WebIDE-Backend with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testGetDiffEntryForCommit() throws GitAPIException, IOException, GitOperationException { ws.write("test", "This is readme", false, true, false); ws.write("README.md", "update readme", false, true, false); Git.wrap(repository).add().addFilepattern("test").call(); ws.write("testUntracked", "testUntracked", false, true, false); ws.remove("README2.md", false); gitMgr.createStash(ws, false, null); // will not contain untracked files diff List<DiffEntry> entries = gitMgr.getDiffEntryForCommit(ws, "[email protected]{0}"); assertEquals(3, entries.size()); assertEquals("README.md", entries.get(0).getOldPath()); assertEquals("README.md", entries.get(0).getNewPath()); assertEquals(MODIFY, entries.get(0).getChangeType()); assertEquals("README2.md", entries.get(1).getOldPath()); assertEquals("/dev/null", entries.get(1).getNewPath()); assertEquals(DELETE, entries.get(1).getChangeType()); assertEquals("/dev/null", entries.get(2).getOldPath()); assertEquals("test", entries.get(2).getNewPath()); assertEquals(ADD, entries.get(2).getChangeType()); }
Example #29
Source File: GitStagedFiles.java From git-code-format-maven-plugin with MIT License | 5 votes |
public void format(CodeFormatters formatters) throws IOException { Git git = new Git(repository); try (Index index = Index.lock(repository); TemporaryFile temporaryDiffFile = TemporaryFile.create(log, "diff-between-unformatted-and-formatted-files")) { DirCacheEditor dirCacheEditor = index.editor(); filePaths.stream() .map(path -> new GitIndexEntry(log, repository, path)) .map(indexEntry -> indexEntry.entryFormatter(formatters)) .forEach(dirCacheEditor::add); dirCacheEditor.finish(); index.write(); try (Repository autoCRLFRepository = new AutoCRLFRepository(git.getRepository().getDirectory(), eolStreamType); OutputStream diffOutput = temporaryDiffFile.newOutputStream()) { new Git(autoCRLFRepository) .diff() .setOutputStream(diffOutput) .setOldTree(treeIterator(repository.readDirCache())) .setNewTree(index.treeIterator()) .call(); } try (InputStream diffInput = temporaryDiffFile.newInputStream()) { git.apply().setPatch(diffInput).call(); } index.commit(); } catch (GitAPIException e) { throw new MavenGitCodeFormatException(e); } }
Example #30
Source File: TestSshGit.java From Jpom with MIT License | 5 votes |
public static void main(String[] args) throws GitAPIException { Git.cloneRepository() .setURI("[email protected]:jiangzeyin/test.git") .setDirectory(new File("D:\\test\\gitssh")) .setTransportConfigCallback(new TransportConfigCallback() { @Override public void configure(Transport transport) { SshTransport sshTransport = (SshTransport) transport; sshTransport.setSshSessionFactory(new JschConfigSessionFactory() { @Override protected void configure(OpenSshConfig.Host hc, Session session) { session.setConfig("StrictHostKeyChecking", "no"); session.setPassword(""); } @Override protected JSch createDefaultJSch(FS fs) throws JSchException { JSch defaultJSch = super.createDefaultJSch(fs); defaultJSch.addIdentity("C:\\Users\\Colorful\\.ssh\\id_rsa.pub"); return defaultJSch; } }); } }) .call(); }