/** * {@inheritDoc} */ @Override protected void decorateBuilder(SCMBuilder<?,?> builder) { ((GitSCMBuilder<?>)builder).withCredentials(credentialsId); }
/** * Converts the {@link #asRefSpecs()} into {@link UserRemoteConfig} instances. * * @return the list of {@link UserRemoteConfig} instances. */ @NonNull public final List<UserRemoteConfig> asRemoteConfigs() { List<UserRemoteConfig> result = new ArrayList<>(1 + additionalRemotes.size()); result.add(new UserRemoteConfig(remote(), remoteName(), joinRefSpecs(asRefSpecs()), credentialsId())); for (AdditionalRemote r : additionalRemotes.values()) { result.add(new UserRemoteConfig(r.remote(), r.remoteName(), joinRefSpecs(r.asRefSpecs()), credentialsId())); } return result; }
/** * {@inheritDoc} */ @NonNull @Override public SCM build(@NonNull SCMHead head, @CheckForNull SCMRevision revision) { GitSCMBuilder<?> builder = newBuilder(head, revision); if (MethodUtils.isOverridden(AbstractGitSCMSource.class, getClass(), "getExtensions")) { builder.withExtensions(getExtensions()); } if (MethodUtils.isOverridden(AbstractGitSCMSource.class, getClass(), "getBrowser")) { builder.withBrowser(getBrowser()); } if (MethodUtils.isOverridden(AbstractGitSCMSource.class, getClass(), "getGitTool")) { builder.withGitTool(getGitTool()); } if (MethodUtils.isOverridden(AbstractGitSCMSource.class, getClass(), "getRefSpecs")) { List<String> specs = new ArrayList<>(); for (RefSpec spec: getRefSpecs()) { specs.add(spec.toString()); } builder.withoutRefSpecs().withRefSpecs(specs); } builder.withTraits(getTraits()); decorate(builder); return builder.build(); }
@Override public GitSCM build() { List<GitSCMExtension> extensions = new ArrayList<>(extensions()); boolean foundClone = false; for (GitSCMExtension e: extensions) { extensions.add(new GitSCMSourceDefaults(head() instanceof TagSCMHead)); SCMRevision revision = revision(); if (revision instanceof AbstractGitSCMSource.SCMRevisionImpl) { asRemoteConfigs(), Collections.singletonList(new BranchSpec(head().getName())), false, Collections.<SubmoduleConfig>emptyList(), browser(), gitTool(), extensions);
return super.build(); } finally { withHead(h);
File cacheDir = AbstractGitSCMSource.getCacheDir(cacheEntry); Git git = Git.with(listener, new EnvVars(EnvVars.masterEnvVars)).in(cacheDir); GitTool tool = gitSCMSource.resolveGitTool(builder.gitTool()); if (tool != null) { git.using(tool.getGitExe()); client.init(); String remoteName = builder.remoteName(); listener.getLogger().println("Setting " + remoteName + " to " + gitSCMSource.getRemote()); client.setRemoteUrl(remoteName, gitSCMSource.getRemote()); listener.getLogger().println("URI syntax exception for '" + remoteName + "' " + ex); client.fetch_().prune().from(remoteURI, builder.asRefSpecs()).execute(); listener.getLogger().println("Done."); return new GitSCMFileSystem(client, gitSCMSource.getRemote(), Constants.R_REMOTES+remoteName+"/"+head.getName(),
/** * Instantiates a new {@link GitSCMBuilder}. * Subclasses should override this method if they want to use a custom {@link GitSCMBuilder} or if they need * to pre-decorare the builder. * * @param head the {@link SCMHead}. * @param revision the {@link SCMRevision}. * @return the {@link GitSCMBuilder} * @see #decorate(GitSCMBuilder) for post-decoration. */ protected GitSCMBuilder<?> newBuilder(@NonNull SCMHead head, @CheckForNull SCMRevision revision) { return new GitSCMBuilder<>(head, revision, getRemote(), getCredentialsId()); }
return super.build(); } finally { withHead(h);
@Override protected void decorateBuilder(SCMBuilder<?, ?> builder) { ((GitSCMBuilder<?>) builder).withCredentials(credentialsId); }