本文整理汇总了Java中hudson.plugins.git.UserRemoteConfig类的典型用法代码示例。如果您正苦于以下问题:Java UserRemoteConfig类的具体用法?Java UserRemoteConfig怎么用?Java UserRemoteConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UserRemoteConfig类属于hudson.plugins.git包,在下文中一共展示了UserRemoteConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: oneBuildBasicMergeFailure
import hudson.plugins.git.UserRemoteConfig; //导入依赖的package包/类
@Test
public void oneBuildBasicMergeFailure() throws Exception {
repository = TestUtilsFactory.createRepositoryWithMergeConflict("test-repo");
File workDir = new File(TestUtilsFactory.WORKDIR,"test-repo");
Git.cloneRepository().setURI("file:///" + repository.getDirectory().getAbsolutePath()).setDirectory(workDir)
.setBare(false)
.setCloneAllBranches(true)
.setNoCheckout(false)
.call().close();
MatrixProjectBuilder builder = new MatrixProjectBuilder()
.setGitRepos(Collections.singletonList(new UserRemoteConfig("file://" + repository.getDirectory().getAbsolutePath(), null, null, null)))
.setUseSlaves(true).setRule(jenkinsRule)
.setStrategy(TestUtilsFactory.STRATEGY_TYPE.ACCUMULATED);
builder.setJobType(MatrixProject.class);
MatrixProject project = (MatrixProject)builder.generateJenkinsJob();
TestUtilsFactory.triggerProject(project);
jenkinsRule.waitUntilNoActivityUpTo(60000);
jenkinsRule.assertBuildStatus(Result.FAILURE, project.getLastBuild());
assertEquals("3 runs for this particular matrix build", 3, project.getLastBuild().getRuns().size());
}
示例2: configurePretestedIntegrationPlugin
import hudson.plugins.git.UserRemoteConfig; //导入依赖的package包/类
private FreeStyleProject configurePretestedIntegrationPlugin(IntegrationStrategy integrationStrategy, String repositoryUrl) throws IOException, ANTLRException, InterruptedException {
FreeStyleProject project = jenkinsRule.createFreeStyleProject();
List<UserRemoteConfig> repoList = new ArrayList<>();
repoList.add(new UserRemoteConfig(repositoryUrl, null, null, null));
List<GitSCMExtension> gitSCMExtensions = new ArrayList<>();
gitSCMExtensions.add(new PretestedIntegrationAsGitPluginExt(integrationStrategy, "master", "origin"));
gitSCMExtensions.add(new PruneStaleBranch());
gitSCMExtensions.add(new CleanCheckout());
GitSCM gitSCM = new GitSCM(repoList,
Collections.singletonList(new BranchSpec("origin/ready/**")),
false, Collections.<SubmoduleConfig>emptyList(),
null, null, gitSCMExtensions);
project.setScm(gitSCM);
project.getPublishersList().add(new PretestedIntegrationPostCheckout());
return project;
}
示例3: configurePretestedIntegrationPlugin
import hudson.plugins.git.UserRemoteConfig; //导入依赖的package包/类
public static FreeStyleProject configurePretestedIntegrationPlugin(JenkinsRule rule, STRATEGY_TYPE type, List<UserRemoteConfig> repoList, String repoName, boolean runOnSlave, String integrationBranch) throws Exception {
FreeStyleProject project = rule.createFreeStyleProject();
if (runOnSlave) {
DumbSlave onlineSlave = rule.createOnlineSlave();
project.setAssignedNode(onlineSlave);
}
List<GitSCMExtension> gitSCMExtensions = new ArrayList<>();
gitSCMExtensions.add(new PretestedIntegrationAsGitPluginExt(type == STRATEGY_TYPE.SQUASH ? new SquashCommitStrategy() : new AccumulatedCommitStrategy(), integrationBranch, repoName));
gitSCMExtensions.add(new PruneStaleBranch());
gitSCMExtensions.add(new CleanCheckout());
project.getPublishersList().add(new PretestedIntegrationPostCheckout());
GitSCM gitSCM = new GitSCM(repoList,
Collections.singletonList(new BranchSpec("*/ready/**")),
false, Collections.<SubmoduleConfig>emptyList(),
null, null, gitSCMExtensions);
project.setScm(gitSCM);
project.save();
return project;
}
示例4: getRemotes
import hudson.plugins.git.UserRemoteConfig; //导入依赖的package包/类
@Nonnull
List<UserRemoteConfig> getRemotes(@Nonnull GitLabSCMSource source) throws GitLabAPIException {
return singletonList(
new UserRemoteConfig(
getProject(projectId, source).getRemote(source),
"origin", getRefSpec().delegate().toString(),
source.getCredentialsId()));
}
示例5: getRemotes
import hudson.plugins.git.UserRemoteConfig; //导入依赖的package包/类
@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;
}
示例6: getSSHCredentials
import hudson.plugins.git.UserRemoteConfig; //导入依赖的package包/类
public static SSHUserPrivateKey getSSHCredentials(BuildContext context, EnvVars envVars) {
SCM scm = context.build.getProject().getScm();
if (!(scm instanceof GitSCM)) {
context.listener.getLogger().println("Error: SCM is not a GitSCM: " + scm.getType());
return null;
}
GitSCM git = (GitSCM) scm;
SSHUserPrivateKey theCreds = null;
for (UserRemoteConfig uc : git.getUserRemoteConfigs()) {
if (uc.getCredentialsId() != null) {
String url = uc.getUrl();
url = GitSCM.getParameterString(url, envVars);
theCreds = CredentialsMatchers
.firstOrNull(
CredentialsProvider.lookupCredentials(SSHUserPrivateKey.class, context.build.getProject(),
ACL.SYSTEM, URIRequirementBuilder.fromUri(url).build()),
CredentialsMatchers.allOf(CredentialsMatchers.withId(uc.getCredentialsId()),
GitClient.CREDENTIALS_MATCHER));
// just choose the first one. there should only be one...
if (theCreds != null) {
break;
}
}
}
return theCreds;
}
示例7: Git
import hudson.plugins.git.UserRemoteConfig; //导入依赖的package包/类
public Git(GitSCM gitSCM, AbstractBuild<?, ?> build, BuildListener listener)
throws IOException, InterruptedException {
String gitExe = gitSCM.getGitExe(build.getBuiltOn(), listener);
EnvVars environment = build.getEnvironment(listener);
this.gitClient = org.jenkinsci.plugins.gitclient.Git.with(listener, environment).in(build.getWorkspace())
.using(gitExe) // only if you want to use Git CLI
.getClient();
// get remote configurations, e.g., URL
List<UserRemoteConfig> remotes = gitSCM.getUserRemoteConfigs();
UserRemoteConfig remoteConfig = remotes.get(0);
this.remote = remoteConfig.getUrl();
listener.getLogger().println(EvoSuiteRecorder.LOG_PREFIX + "Remote config " + remoteConfig.toString());
// get key's (i.e., username-password, ssh key, etc) hash
String credentialID = remoteConfig.getCredentialsId();
if (credentialID == null || credentialID.equals("null")) {
listener.getLogger().println(EvoSuiteRecorder.LOG_PREFIX + "No credentials defined.");
// TODO: should we throw an exception and make the build fail?
} else {
// get key (i.e., username-password or ssh key / passphrase)
StandardUsernameCredentials credentials = this.getCredentials(credentialID);
this.gitClient.setCredentials(credentials);
this.gitClient.addDefaultCredentials(credentials);
}
}
示例8: provideGitSCM
import hudson.plugins.git.UserRemoteConfig; //导入依赖的package包/类
public static GitSCM provideGitSCM() {
return new GitSCM(newArrayList(
new UserRemoteConfig("https://github.com/user/dropwizard",
"", "+refs/pull/*:refs/remotes/origin/pr/*", "")),
newArrayList(new BranchSpec("${sha1}")),
false,
null,
null,
"",
null);
}
示例9: testBasicMerge
import hudson.plugins.git.UserRemoteConfig; //导入依赖的package包/类
@Test
public void testBasicMerge() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();
List<UserRemoteConfig> remotes = new ArrayList<UserRemoteConfig>();
remotes.add(new UserRemoteConfig(repo.getPath(), "origin", "master", null));
List<BranchSpec> branches = new ArrayList<BranchSpec>();
branches.add(new BranchSpec("master"));
p.setScm(new GitSCM(remotes, branches, false, null, null, null, null));
// Init repo with release and feature branch.
GitClient client = g.gitClient(repo);
client.init();
g.touchAndCommit(repo, "init");
client.checkout("HEAD", "r1336");
g.touchAndCommit(repo, "r1336");
client.checkout("HEAD", "c3");
g.touchAndCommit(repo, "c3");
// Custom builder that merges feature branch with release branch using AdvancedSCMManager.
p.getBuildersList().add(new TestBuilder() {
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
try {
AdvancedSCMManager amm = SCMManagerFactory.getManager(build, launcher, listener);
amm.update("r1336");
amm.mergeWorkspaceWith("c3", null);
amm.commit("merge c3", "test <[email protected]>");
return true;
} catch (Exception e) {
e.printStackTrace(listener.getLogger());
return false;
}
}
});
// Assert file is here (should be after successful merge)
g.buildAndCheck(p, "c3");
}
示例10: createRevisionParameterAction_pushCommitRequestWith2Remotes
import hudson.plugins.git.UserRemoteConfig; //导入依赖的package包/类
@Theory
public void createRevisionParameterAction_pushCommitRequestWith2Remotes(GitLabPushRequestSamples samples) throws Exception {
PushHook hook = samples.pushCommitRequest();
GitSCM gitSCM = new GitSCM(Arrays.asList(new UserRemoteConfig("[email protected]:test.git", null, null, null),
new UserRemoteConfig("[email protected]:fork.git", "fork", null, null)),
Collections.singletonList(new BranchSpec("")),
false, Collections.<SubmoduleConfig>emptyList(),
null, null, null);
RevisionParameterAction revisionParameterAction = new PushHookTriggerHandlerImpl().createRevisionParameter(hook, gitSCM);
assertThat(revisionParameterAction, is(notNullValue()));
assertThat(revisionParameterAction.commit, is(hook.getAfter()));
assertFalse(revisionParameterAction.canOriginateFrom(new ArrayList<RemoteConfig>()));
}
示例11: succesWithDefaultConfiguration2RepositoriesWithoutNames
import hudson.plugins.git.UserRemoteConfig; //导入依赖的package包/类
/**
* Test case 1-1:
* <p>
* * Two git repositories is configured in the git scm plugin
* * repo1 will default be named 'origin' by the git scm plugin
* * repo2 will default be named 'origin1' by the git scm plugin
* * pretested integration plugin is not configured, so default to:
* * integration branch: master
* * integration repo: origin
* * job should be a success the default plugin configuration matches
*
* @throws java.lang.Exception
*/
// This test should also be working, and should integrate repository 'repo1' as this should default be given the name 'origin' by the git scm and this is also our default name we use in the plugin when nothing else stated.
@Test
public void succesWithDefaultConfiguration2RepositoriesWithoutNames() throws Exception {
repository = TestUtilsFactory.createValidRepository("repo1");
Repository repo2 = TestUtilsFactory.createValidRepository("repo2");
List<UserRemoteConfig> userRemoteConfig = new ArrayList<>();
userRemoteConfig.add(new UserRemoteConfig("file://" + repository.getDirectory().getAbsolutePath(), null, null, null));
userRemoteConfig.add(new UserRemoteConfig("file://" + repo2.getDirectory().getAbsolutePath(), null, null, null));
FreeStyleProject project = TestUtilsFactory.configurePretestedIntegrationPlugin(jenkinsRule, TestUtilsFactory.STRATEGY_TYPE.SQUASH, userRemoteConfig, null, true);
TestUtilsFactory.triggerProject(project);
jenkinsRule.waitUntilNoActivityUpTo(60000);
TestUtilsFactory.destroyRepo(repo2);
Iterator<FreeStyleBuild> biterator = project.getBuilds().iterator();
while (biterator.hasNext()) {
FreeStyleBuild bitstuff = biterator.next();
String text = jenkinsRule.createWebClient().getPage(bitstuff, "console").asText();
System.out.println("=====BUILD-LOG=====");
System.out.println(text);
System.out.println("=====BUILD-LOG=====");
if (text.contains("push origin :origin/ready/feature_1")) {
assertEquals("Unexpected build result.", bitstuff.getResult(), Result.SUCCESS);
} else {
assertEquals("Unexpected build result.", bitstuff.getResult(), Result.NOT_BUILT);
}
}
}
示例12: failWith2RepositoriesWithNoMatchingName
import hudson.plugins.git.UserRemoteConfig; //导入依赖的package包/类
/**
* When more than 1 git repository is chosen, and the user has specified
* repository names which do not match what is configured in the pretested
* integration plugin. We should fail the build.
*
* @throws java.lang.Exception
*/
@Test
public void failWith2RepositoriesWithNoMatchingName() throws Exception {
repository = TestUtilsFactory.createValidRepository("repo1");
Repository repo2 = TestUtilsFactory.createValidRepository("repo2");
List<UserRemoteConfig> userRemoteConfig = new ArrayList<>();
userRemoteConfig.add(new UserRemoteConfig("file://" + repository.getDirectory().getAbsolutePath(), "repo1", null, null));
userRemoteConfig.add(new UserRemoteConfig("file://" + repo2.getDirectory().getAbsolutePath(), "repo2", null, null));
FreeStyleProject project = TestUtilsFactory.configurePretestedIntegrationPlugin(jenkinsRule, TestUtilsFactory.STRATEGY_TYPE.SQUASH, userRemoteConfig, null, true);
TestUtilsFactory.triggerProject(project);
jenkinsRule.waitUntilNoActivityUpTo(60000);
TestUtilsFactory.destroyRepo(repo2);
// FIXME when this test works with first build, we should loop over all builds and improve the test
FreeStyleBuild build = project.getBuilds().getFirstBuild();
String text = jenkinsRule.createWebClient().getPage(build, "console").asText();
System.out.println("=====BUILD-LOG=====");
System.out.println(text);
System.out.println("=====BUILD-LOG=====");
assertEquals("Unexpected build result.", Result.FAILURE, build.getResult());
}
示例13: successWithMatchingRepositoryNames
import hudson.plugins.git.UserRemoteConfig; //导入依赖的package包/类
/**
* TODO: isn't this a copy of
* {@link GeneralBehaviourIT#remoteOrigin1WithMoreThan1RepoShouldBeSuccessfulFirstRepo()}
* <p>
* When more than 1 git repository is chosen, and the user has specified
* repository names which do match what is configured in the pretested
* integration plugin. We should get 2 builds, one of which should be
* NOT_BUILT, the other one should be SUCCESS.
*
* @throws java.lang.Exception
*/
//FIXME this test fails in as the plugin tries to merge changes from repository 2 into repository 1.
// So a bug in the plugin allows for trying to run integration, without checking that we're started with the correct
// repository, which is the one we configure in our pretested integration part of the job.
// The configuration below should only allow us to integrate things on repo1.
@Test
public void successWithMatchingRepositoryNames() throws Exception {
Repository repo1 = TestUtilsFactory.createValidRepository("repo1");
Repository repo2 = TestUtilsFactory.createValidRepository("repo2");
List<UserRemoteConfig> userRemoteConfig = new ArrayList<>();
userRemoteConfig.add(new UserRemoteConfig("file://" + repo1.getDirectory().getAbsolutePath(), "repo1", null, null));
userRemoteConfig.add(new UserRemoteConfig("file://" + repo2.getDirectory().getAbsolutePath(), "repo2", null, null));
FreeStyleProject project = TestUtilsFactory.configurePretestedIntegrationPlugin(jenkinsRule, TestUtilsFactory.STRATEGY_TYPE.SQUASH, userRemoteConfig, "repo1", true);
TestUtilsFactory.triggerProject(project);
jenkinsRule.waitUntilNoActivityUpTo(60000);
TestUtilsFactory.destroyRepo(repo1, repo2);
Iterator<FreeStyleBuild> biterator = project.getBuilds().iterator();
while (biterator.hasNext()) {
FreeStyleBuild bitstuff = biterator.next();
String text = jenkinsRule.createWebClient().getPage(bitstuff, "console").asText();
System.out.println("=====BUILD-LOG=====");
System.out.println(text);
System.out.println("=====BUILD-LOG=====");
if (text.contains("No revision matches configuration in 'Integration repository'")) {
assertEquals("Unexpected build result.", Result.NOT_BUILT, bitstuff.getResult());
} else {
assertEquals("Unexpected build result.", Result.SUCCESS, bitstuff.getResult());
}
}
}
示例14: successWithDefaultConfiguration
import hudson.plugins.git.UserRemoteConfig; //导入依赖的package包/类
/**
* TODO: This one is very much redundant. We've covered the case multiple
* times
* <p>
* We should work with out of the box default configuration. This one should
* finish successfully with the merge going well.
* <p>
* Expect: Build success.
*
* @throws Exception
*/
@Test
public void successWithDefaultConfiguration() throws Exception {
Repository repo1 = TestUtilsFactory.createValidRepository("repo1");
List<UserRemoteConfig> userRemoteConfig = new ArrayList<>();
userRemoteConfig.add(new UserRemoteConfig("file://" + repo1.getDirectory().getAbsolutePath(), null, null, null));
FreeStyleProject project = TestUtilsFactory.configurePretestedIntegrationPlugin(jenkinsRule, TestUtilsFactory.STRATEGY_TYPE.SQUASH, userRemoteConfig, null, true);
TestUtilsFactory.triggerProject(project);
jenkinsRule.waitUntilNoActivityUpTo(60000);
Iterator<FreeStyleBuild> biterator = project.getBuilds().iterator();
while (biterator.hasNext()) {
FreeStyleBuild bitstuff = biterator.next();
String text = jenkinsRule.createWebClient().getPage(bitstuff, "console").asText();
System.out.println("=====BUILD-LOG=====");
System.out.println(text);
System.out.println("=====BUILD-LOG=====");
}
TestUtilsFactory.destroyRepo(repo1);
Result buildResult = project.getBuilds().getFirstBuild().getResult();
assertEquals("Unexpected build result.", buildResult, Result.SUCCESS);
}
示例15: testCredentialsSupportForAbstractProjectTypes
import hudson.plugins.git.UserRemoteConfig; //导入依赖的package包/类
@Test
public void testCredentialsSupportForAbstractProjectTypes() throws Exception {
assumeTrue(pw != null && repo != null && uName != null);
cloneTestRepositoryAndPrepareABranch();
SystemCredentialsProvider scp = (SystemCredentialsProvider)jenkinsRule.getInstance().getExtensionList("com.cloudbees.plugins.credentials.SystemCredentialsProvider").get(0);
UsernamePasswordCredentialsImpl unpwCred = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, "pipCredentials","description", uName, pw);
scp.getCredentials().add(unpwCred);
scp.save();
List<UserRemoteConfig> urcList = new ArrayList<>();
UserRemoteConfig urc = new UserRemoteConfig(repo,null,null,"pipCredentials");
urcList.add(urc);
FreeStyleProject freeStyle = TestUtilsFactory.configurePretestedIntegrationPlugin(jenkinsRule, TestUtilsFactory.STRATEGY_TYPE.SQUASH, urcList,"origin", false);
jenkinsRule.buildAndAssertSuccess(freeStyle);
}