Search in sources :

Example 1 with UserRemoteConfig

use of hudson.plugins.git.UserRemoteConfig in project gitlab-branch-source-plugin by Argelbargel.

the class GitLabSCMMergeRequestHead method getRemotes.

@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;
}
Also used : ArrayList(java.util.ArrayList) UserRemoteConfig(hudson.plugins.git.UserRemoteConfig) Nonnull(javax.annotation.Nonnull)

Example 2 with UserRemoteConfig

use of hudson.plugins.git.UserRemoteConfig in project workflow-cps-plugin by jenkinsci.

the class CpsScmFlowDefinitionTest method usingParameter.

@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");
    // TODO SCMFileSystem.of cannot pick up build parameters
    def.setLightweight(false);
    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")))));
}
Also used : StringParameterDefinition(hudson.model.StringParameterDefinition) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) BranchSpec(hudson.plugins.git.BranchSpec) StringParameterValue(hudson.model.StringParameterValue) SubmoduleConfig(hudson.plugins.git.SubmoduleConfig) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) ParametersAction(hudson.model.ParametersAction) GitSCM(hudson.plugins.git.GitSCM) UserRemoteConfig(hudson.plugins.git.UserRemoteConfig) GitSCMExtension(hudson.plugins.git.extensions.GitSCMExtension) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Example 3 with UserRemoteConfig

use of hudson.plugins.git.UserRemoteConfig in project workflow-cps-plugin by jenkinsci.

the class CpsScmFlowDefinitionTest method usingParameterInScriptPath.

@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")))));
}
Also used : StringParameterDefinition(hudson.model.StringParameterDefinition) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) BranchSpec(hudson.plugins.git.BranchSpec) StringParameterValue(hudson.model.StringParameterValue) SubmoduleConfig(hudson.plugins.git.SubmoduleConfig) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) ParametersAction(hudson.model.ParametersAction) GitSCM(hudson.plugins.git.GitSCM) UserRemoteConfig(hudson.plugins.git.UserRemoteConfig) GitSCMExtension(hudson.plugins.git.extensions.GitSCMExtension) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Example 4 with UserRemoteConfig

use of hudson.plugins.git.UserRemoteConfig in project memory-map-plugin by Praqma.

the class TestUtils method configureGit.

public static FreeStyleProject configureGit(FreeStyleProject project, String branchName, String repository) throws IOException {
    List<UserRemoteConfig> repos = Collections.singletonList(new UserRemoteConfig(repository, null, null, null));
    GitSCM gitSCM = new GitSCM(repos, Collections.singletonList(new BranchSpec(branchName)), false, Collections.<SubmoduleConfig>emptyList(), null, null, Collections.EMPTY_LIST);
    project.setScm(gitSCM);
    return project;
}
Also used : BranchSpec(hudson.plugins.git.BranchSpec) UserRemoteConfig(hudson.plugins.git.UserRemoteConfig) GitSCM(hudson.plugins.git.GitSCM)

Aggregations

UserRemoteConfig (hudson.plugins.git.UserRemoteConfig)4 BranchSpec (hudson.plugins.git.BranchSpec)3 GitSCM (hudson.plugins.git.GitSCM)3 ParametersAction (hudson.model.ParametersAction)2 ParametersDefinitionProperty (hudson.model.ParametersDefinitionProperty)2 StringParameterDefinition (hudson.model.StringParameterDefinition)2 StringParameterValue (hudson.model.StringParameterValue)2 SubmoduleConfig (hudson.plugins.git.SubmoduleConfig)2 GitSCMExtension (hudson.plugins.git.extensions.GitSCMExtension)2 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)2 Test (org.junit.Test)2 Issue (org.jvnet.hudson.test.Issue)2 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1