當前位置: 首頁>>代碼示例>>Java>>正文


Java GHRepository.createCommitStatus方法代碼示例

本文整理匯總了Java中org.kohsuke.github.GHRepository.createCommitStatus方法的典型用法代碼示例。如果您正苦於以下問題:Java GHRepository.createCommitStatus方法的具體用法?Java GHRepository.createCommitStatus怎麽用?Java GHRepository.createCommitStatus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.kohsuke.github.GHRepository的用法示例。


在下文中一共展示了GHRepository.createCommitStatus方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createCommitStatus

import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
private void createCommitStatus(AbstractBuild<?, ?> build, TaskListener listener, String message, GHRepository repo, GHCommitState state) throws GhprcCommitStatusException {
    GhprcCause cause = Ghprc.getCause(build);
    
    String sha1 = cause.getCommit();
    String url = Jenkins.getInstance().getRootUrl() + build.getUrl();
    if (!StringUtils.isEmpty(statusUrl)) {
        url = Ghprc.replaceMacros(build, listener, statusUrl);
    }
    String context = Util.fixEmpty(commitStatusContext);
    context = Ghprc.replaceMacros(build, listener, context);
    
    listener.getLogger().println(String.format("Setting status of %s to %s with url %s and message: '%s'", sha1, state, url, message));
    if (context != null) {
        listener.getLogger().println(String.format("Using context: " + context));
    }
    try {
        repo.createCommitStatus(sha1, state, url, message, context);
    } catch (IOException e) {
        throw new GhprcCommitStatusException(e, state, message, cause.getPullID());
    }
}
 
開發者ID:bratchenko,項目名稱:jenkins-github-pull-request-comments,代碼行數:22,代碼來源:GhprcSimpleStatus.java

示例2: run

import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
@Override
protected Void run() throws Exception {
    // Figure out which GitHub repository to send the request to
    checkArgument(nonNull(config.getState()), "Missing required parameter 'state'");

    GHRepository repository = resolveRepository();
    String statusContext = resolveContext();

    final GitHubPRCause cause = run.getCause(GitHubPRCause.class);
    if (isNull(cause)) {
        throw new AbortException(FUNC_NAME + " requires run to be triggered by GitHub Pull Request");
    }

    // Update the commit status
    log.getLogger().printf("Setting pull request status %s to %s with message: %s%n",
            statusContext,
            config.getState(),
            config.getMessage()
    );
    String buildUrl = null;
    final JenkinsLocationConfiguration globalConfig = JenkinsLocationConfiguration.get();
    if (nonNull(globalConfig)) {
        buildUrl = globalConfig.getUrl();
    }
    if (isEmpty(buildUrl)) {
        log.error("Jenkins Location is not configured in system settings. Cannot create a 'details' link.");
        buildUrl = null;
    } else {
        buildUrl += run.getUrl();
    }

    repository.createCommitStatus(cause.getHeadSha(),
            config.getState(),
            buildUrl,
            config.getMessage(),
            statusContext);
    return null;
}
 
開發者ID:KostyaSha,項目名稱:github-integration-plugin,代碼行數:39,代碼來源:SetCommitStatusExecution.java

示例3: onBuildTriggered

import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
public void onBuildTriggered(GhprcTrigger trigger, GhprcPullRequest pr, GHRepository ghRepository) throws GhprcCommitStatusException {
    StringBuilder sb = new StringBuilder();
    GHCommitState state = GHCommitState.PENDING;
    
    AbstractProject<?, ?> project = trigger.getActualProject();
    
    String context = Util.fixEmpty(commitStatusContext);
    context = Ghprc.replaceMacros(project, context);
    
    if (!StringUtils.isEmpty(triggeredStatus)) {
        sb.append(Ghprc.replaceMacros(project, triggeredStatus));
    } else {
        sb.append("Build triggered.");
        if (pr.isMergeable()) {
            sb.append(" sha1 is merged.");
        } else {
            sb.append(" sha1 is original commit.");
        }
    }
    
    String url = Ghprc.replaceMacros(project, statusUrl);

    String message = sb.toString();
    try {
        ghRepository.createCommitStatus(pr.getHead(), state, url, message, context);
    } catch (IOException e) {
        throw new GhprcCommitStatusException(e, state, message, pr.getId());
    }
}
 
開發者ID:bratchenko,項目名稱:jenkins-github-pull-request-comments,代碼行數:30,代碼來源:GhprcSimpleStatus.java

示例4: onCompleted

import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
@Override
public void onCompleted(final DynamicBuild build, final TaskListener listener) {
    final String sha1 = build.getSha();
    if (sha1 == null) {
        return;
    }

    final GHRepository repository = getGithubRepository(build);
    final GHCommitState state;
    String msg;
    final Result result = build.getResult();
    if (result.isBetterOrEqualTo(SUCCESS)) {
        state = GHCommitState.SUCCESS;
        msg = "Success";
    } else if (result.isBetterOrEqualTo(UNSTABLE)) {
        state = GHCommitState.FAILURE;
        msg = "Unstable";
    } else {
        state = GHCommitState.FAILURE;
        msg = "Failed";
    }
    if (build.isSkipped()) {
        msg += " - Skipped";
    }
    try {
        listener.getLogger().println("setting commit status on Github for " + repository.getHtmlUrl() + "/commit/" + sha1);
        repository.createCommitStatus(sha1, state, build.getFullUrl(), msg, getContext(build));
    } catch (final Exception e) {
        printErrorToBuildConsole(listener, e);
    }

}
 
開發者ID:groupon,項目名稱:DotCi,代碼行數:33,代碼來源:CommitStatusUpdateRunListener.java

示例5: setCommitStatus

import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
private void setCommitStatus(final BuildCause cause, final DynamicProject project) {
    final BuildCause buildCause = cause;
    final String sha = buildCause.getSha();
    if (sha != null) {
        final GHRepository githubRepository = getGithubRepository(project);
        final String context = buildCause.getPullRequestNumber() != null ? "DotCi/PR" : "DotCi/push";
        try {
            githubRepository.createCommitStatus(sha, GHCommitState.PENDING, getJenkinsRootUrl(), "Build in queue.", context);
        } catch (final IOException e) {
            LOGGER.log(Level.WARNING, "Failed to Update commit status", e);
        }
    }
}
 
開發者ID:groupon,項目名稱:DotCi,代碼行數:14,代碼來源:CommitStatusUpdateQueueListener.java

示例6: updateCommitStatus

import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
void updateCommitStatus(String revision, String pipelineStage, String trackbackURL, String repository, GHCommitState state,
                        String usernameToUse, String passwordToUse, String oauthAccessTokenToUse, String endPointToUse) throws Exception {
    GitHub github = createGitHubClient(usernameToUse, passwordToUse, oauthAccessTokenToUse, endPointToUse);
    GHRepository ghRepository = github.getRepository(repository);
    ghRepository.createCommitStatus(revision, state, trackbackURL, "", pipelineStage);
}
 
開發者ID:gocd-contrib,項目名稱:gocd-build-status-notifier,代碼行數:7,代碼來源:GitHubProvider.java

示例7: call

import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
@Override
public Void call() throws IOException, InterruptedException {
  GHRepository repository = gitHub.getRepository(repoName);
  repository.createCommitStatus(commitSHA, state, url, description, context);
  return null;
}
 
開發者ID:tox4j,項目名稱:upsource-bot,代碼行數:7,代碼來源:GitHubCommitStatusTask.java


注:本文中的org.kohsuke.github.GHRepository.createCommitStatus方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。