本文整理汇总了Java中org.eclipse.jgit.api.PushCommand.setCredentialsProvider方法的典型用法代码示例。如果您正苦于以下问题:Java PushCommand.setCredentialsProvider方法的具体用法?Java PushCommand.setCredentialsProvider怎么用?Java PushCommand.setCredentialsProvider使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.api.PushCommand
的用法示例。
在下文中一共展示了PushCommand.setCredentialsProvider方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: push
import org.eclipse.jgit.api.PushCommand; //导入方法依赖的package包/类
/**
* Push current state to remote repository.
*
* @param repositoryName for which repository
* @param username committer username
* @param password committer password
*/
public void push(String repositoryName, String username, String password)
{
RepositoryContext repositoryContext = repositoryByName.get(repositoryName);
try
{
PushCommand pushCommand = repositoryContext.git.push();
pushCommand.setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password));
pushCommand.call();
}
catch (GitAPIException e)
{
throw new RuntimeException(e);
}
}
示例2: call
import org.eclipse.jgit.api.PushCommand; //导入方法依赖的package包/类
public Git call(final GitOperationsStep gitOperationsStep, Git git,
CredentialsProvider cp, String gitRepoUrl, File gitRepoFolder)
throws IllegalArgumentException, IOException,
InvalidRemoteException, TransportException, GitAPIException {
PushCommand pc = git.push().setDryRun(dryRun).setForce(force)
.setThin(thin);
if (cp != null) {
pc = pc.setCredentialsProvider(cp);
}
if (!Const.isEmpty(this.receivePack)) {
pc = pc.setReceivePack(gitOperationsStep
.environmentSubstitute(receivePack));
}
if (!Const.isEmpty(this.referenceToPush)) {
pc = pc.add(gitOperationsStep
.environmentSubstitute(this.referenceToPush));
}
if (!Const.isEmpty(this.remote)) {
pc = pc.setRemote(gitOperationsStep
.environmentSubstitute(this.remote));
}
if (this.pushAllBranches) {
pc = pc.setPushAll();
}
if (this.pushAllTags) {
pc = pc.setPushTags();
}
pc.call();
return git;
}
示例3: assertCodeChangeTriggersWorkingBuild
import org.eclipse.jgit.api.PushCommand; //导入方法依赖的package包/类
protected Build assertCodeChangeTriggersWorkingBuild(final String projectName, Build firstBuild) throws Exception {
File cloneDir = new File(getBasedir(), "target/projects/" + projectName);
String gitUrl = asserGetAppGitCloneURL(forgeClient, projectName);
Git git = ForgeClientAsserts.assertGitCloneRepo(gitUrl, cloneDir);
// lets make a dummy commit...
File readme = new File(cloneDir, "ReadMe.md");
boolean mustAdd = false;
String text = "";
if (readme.exists()) {
text = IOHelpers.readFully(readme);
} else {
mustAdd = true;
}
text += "\nupdated at: " + new Date();
Files.writeToFile(readme, text, Charset.defaultCharset());
if (mustAdd) {
AddCommand add = git.add().addFilepattern("*").addFilepattern(".");
add.call();
}
LOG.info("Committing change to " + readme);
CommitCommand commit = git.commit().setAll(true).setAuthor(forgeClient.getPersonIdent()).setMessage("dummy commit to trigger a rebuild");
commit.call();
PushCommand command = git.push();
command.setCredentialsProvider(forgeClient.createCredentialsProvider());
command.setRemote("origin").call();
LOG.info("Git pushed change to " + readme);
// now lets wait for the next build to start
int nextBuildNumber = firstBuild.getNumber() + 1;
Asserts.assertWaitFor(10 * 60 * 1000, new Block() {
@Override
public void invoke() throws Exception {
JobWithDetails job = assertJob(projectName);
Build lastBuild = job.getLastBuild();
assertThat(lastBuild.getNumber()).describedAs("Waiting for latest build for job " + projectName + " to start").isGreaterThanOrEqualTo(nextBuildNumber);
}
});
return ForgeClientAsserts.assertBuildCompletes(forgeClient, projectName);
}
示例4: execute
import org.eclipse.jgit.api.PushCommand; //导入方法依赖的package包/类
@Override
public void execute(Wandora wandora, Context context) {
try {
Git git = getGit();
if(git != null) {
if(isNotEmpty(getGitRemoteUrl())) {
if(pushUI == null) {
pushUI = new PushUI();
}
pushUI.setPassword(getPassword());
pushUI.setUsername(getUsername());
pushUI.setRemoteUrl(getGitRemoteUrl());
pushUI.openInDialog();
if(pushUI.wasAccepted()) {
setDefaultLogger();
setLogTitle("Git push");
String username = pushUI.getUsername();
String password = pushUI.getPassword();
String remoteUrl = pushUI.getRemoteUrl();
setUsername(username);
setPassword(password);
// setGitRemoteUrl(remoteUrl);
PushCommand push = git.push();
log("Pushing local changes to upstream.");
if(username != null && username.length() > 0) {
CredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider( username, password );
push.setCredentialsProvider(credentialsProvider);
}
Iterable<PushResult> pushResults = push.call();
for(PushResult pushResult : pushResults) {
String pushResultMessage = pushResult.getMessages();
if(isNotEmpty(pushResultMessage)) {
log(pushResultMessage);
}
}
log("Ready.");
}
}
else {
log("Repository has no remote origin and can't be pushed. "
+"Initialize repository by cloning remote repository to set the remote origin.");
}
}
else {
logAboutMissingGitRepository();
}
}
catch(TransportException tre) {
if(tre.toString().contains("origin: not found.")) {
log("Git remote origin is not found. Check the remote url and remote git repository.");
}
}
catch(GitAPIException gae) {
log(gae.toString());
}
catch(NoWorkTreeException nwte) {
log(nwte.toString());
}
catch(Exception e) {
log(e);
}
setState(WAIT);
}