public static List<UserRemoteConfig> createRepoList(String url, String credentialsId) { List<UserRemoteConfig> repoList = new ArrayList<UserRemoteConfig>(); repoList.add(new UserRemoteConfig(url, null, null, credentialsId)); return repoList; }
@Nonnull @Override List<UserRemoteConfig> getRemotes(@Nonnull GitLabSCMSource source) throws GitLabAPIException { List<UserRemoteConfig> remotes = new ArrayList<>(2); remotes.add(new UserRemoteConfig( getProject(getProjectId(), source).getRemote(source), "merge-request", "", source.getCredentialsId())); if (merge) { remotes.addAll(targetBranch.getRemotes(source)); } return remotes; }
/** * 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; }
@Nonnull List<UserRemoteConfig> getRemotes(@Nonnull GitLabSCMSource source) throws GitLabAPIException { return singletonList( new UserRemoteConfig( getProject(projectId, source).getRemote(source), "origin", getRefSpec().delegate().toString(), source.getCredentialsId())); }
/** * @return the {@link UserRemoteConfig} instances. * @deprecated use {@link GitSCMBuilder#asRemoteConfigs()} */ @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("3.4.0") protected List<UserRemoteConfig> getRemoteConfigs() { List<RefSpec> refSpecs = getRefSpecs(); List<UserRemoteConfig> result = new ArrayList<>(refSpecs.size()); String remote = getRemote(); for (RefSpec refSpec : refSpecs) { result.add(new UserRemoteConfig(remote, getRemoteName(), refSpec.toString(), getCredentialsId())); } return result; }
refspec = cfg.getFetchRefSpecs().get(0).toString(); userRemoteConfigs.add(new UserRemoteConfig(url, cfg.getName(), refspec, null));
Collections.singletonList(new UserRemoteConfig(gitSource.getUri(), null, null, null)), branchSpecs, false,
@Issue("JENKINS-42836") @Test public void usingParameterInScriptPath() throws Exception { sampleRepo.init(); sampleRepo.write("flow.groovy", "echo 'version one'"); sampleRepo.git("add", "flow.groovy"); sampleRepo.write("otherFlow.groovy", "echo 'version two'"); sampleRepo.git("add", "otherFlow.groovy"); sampleRepo.git("commit", "--all", "--message=commits"); WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); CpsScmFlowDefinition def = new CpsScmFlowDefinition(new GitSCM(Collections.singletonList(new UserRemoteConfig(sampleRepo.fileUrl(), null, null, null)), Collections.singletonList(new BranchSpec("master")), false, Collections.<SubmoduleConfig>emptyList(), null, null, Collections.<GitSCMExtension>emptyList()), "${SCRIPT_PATH}"); p.setDefinition(def); p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("SCRIPT_PATH", "flow.groovy"))); r.assertLogContains("version one", r.assertBuildStatusSuccess(p.scheduleBuild2(0))); r.assertLogContains("version two", r.assertBuildStatusSuccess(p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("SCRIPT_PATH", "otherFlow.groovy"))))); } }
@Issue("JENKINS-28447") @Test public void usingParameter() throws Exception { sampleRepo.init(); sampleRepo.write("flow.groovy", "echo 'version one'"); sampleRepo.git("add", "flow.groovy"); sampleRepo.git("commit", "--message=one"); sampleRepo.git("tag", "one"); sampleRepo.write("flow.groovy", "echo 'version two'"); sampleRepo.git("commit", "--all", "--message=two"); WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); CpsScmFlowDefinition def = new CpsScmFlowDefinition(new GitSCM(Collections.singletonList(new UserRemoteConfig(sampleRepo.fileUrl(), null, null, null)), Collections.singletonList(new BranchSpec("${VERSION}")), false, Collections.<SubmoduleConfig>emptyList(), null, null, Collections.<GitSCMExtension>emptyList()), "flow.groovy"); def.setLightweight(false); // TODO SCMFileSystem.of cannot pick up build parameters p.setDefinition(def); p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("VERSION", "master"))); r.assertLogContains("version two", r.assertBuildStatusSuccess(p.scheduleBuild2(0))); r.assertLogContains("version one", r.assertBuildStatusSuccess(p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("VERSION", "one"))))); }