当前位置: 首页>>代码示例>>Java>>正文


Java PushCommand.setCredentialsProvider方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:23,代码来源:GitTestSupport.java

示例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;
}
 
开发者ID:ivylabs,项目名称:ivy-pdi-git-steps,代码行数:32,代码来源:PushGitCommand.java

示例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);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:50,代码来源:ForgeTestSupport.java

示例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);
}
 
开发者ID:wandora-team,项目名称:wandora,代码行数:73,代码来源:Push.java


注:本文中的org.eclipse.jgit.api.PushCommand.setCredentialsProvider方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。