public ReleaseRepository(URIish gitUri, String repoName) { this.gitUri = gitUri.toString(); this.targetRepoPrivateUri = gitUri.toPrivateASCIIString(); this.repositoryName = repoName; targetRepoUri = false; }
private void addRemoteRepoToConfig(GitClient client) throws InterruptedException { GitSCM gitScm = getJenkinsScm(); for (RemoteConfig uc : gitScm.getRepositories()) { if (client.getRemoteUrl(uc.getName()) == null) client.setRemoteUrl(uc.getName(), uc.getURIs().get(0).toPrivateASCIIString()); } }
@Override public void execute() throws GitException, InterruptedException { ArgumentListBuilder args = new ArgumentListBuilder(); args.add("push", remote.toPrivateASCIIString()); if (refspec != null) { args.add(refspec); } if (force) { args.add("-f"); } if (tags) { args.add("--tags"); } if (!isAtLeastVersion(1,9,0,0) && isShallowRepository()) { throw new GitException("Can't push from shallow repository using git client older than 1.9.0"); } StandardCredentials cred = credentials.get(remote.toPrivateString()); if (cred == null) cred = defaultCredentials; launchCommandWithCredentials(args, workspace, cred, remote, timeout); // Ignore output for now as there's many different formats // That are possible. } };
try { if (first) { git.setRemoteUrl(remoteRepository.getName(), url.toPrivateASCIIString()); first = false; } else { git.addRemoteUrl(remoteRepository.getName(), url.toPrivateASCIIString());
if (dialog.open() == Window.OK) { final String path = wizard.getPath(); final String uri = wizard.getUri().toPrivateASCIIString(); final SubmoduleAddOperation op = new SubmoduleAddOperation(repo, path, uri);
@Override public void execute() throws GitException, InterruptedException { try (Repository repo = getRepository()) { RefSpec ref = (refspec != null) ? new RefSpec(fixRefSpec(repo)) : Transport.REFSPEC_PUSH_ALL; listener.getLogger().println("RefSpec is \""+ref+"\"."); Git g = git(repo); Config config = g.getRepository().getConfig(); config.setString("remote", "org_jenkinsci_plugins_gitclient_JGitAPIImpl", "url", remote.toPrivateASCIIString()); org.eclipse.jgit.api.PushCommand pc = g.push().setRemote("org_jenkinsci_plugins_gitclient_JGitAPIImpl").setRefSpecs(ref) .setProgressMonitor(new JGitProgressMonitor(listener)) .setCredentialsProvider(getProvider()) .setForce(force); if(tags) { pc.setPushTags(); } Iterable<PushResult> results = pc.call(); for(PushResult result:results) for(RemoteRefUpdate update:result.getRemoteUpdates()) { RemoteRefUpdate.Status status = update.getStatus(); if(!OK.equals(status)&&!UP_TO_DATE.equals(status)) { throw new GitException(update.getMessage() + " " + status + " for '" + ref + "' refspec '" + refspec + "' to " + remote.toPrivateASCIIString()); } } config.unset("remote", "org_jenkinsci_plugins_gitclient_JGitAPIImpl", "url"); } catch (IOException | JGitInternalException | GitAPIException e) { throw new GitException(e); } }