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


Java GHCommitState类代码示例

本文整理汇总了Java中org.kohsuke.github.GHCommitState的典型用法代码示例。如果您正苦于以下问题:Java GHCommitState类的具体用法?Java GHCommitState怎么用?Java GHCommitState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GHCommitState类属于org.kohsuke.github包,在下文中一共展示了GHCommitState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onEmittedResource

import org.kohsuke.github.GHCommitState; //导入依赖的package包/类
/**
 * This method is invoked when a new {@link GitRevision} has been emitted.
 *
 * @param holder
 * @param emitter
 */
@Override
@SneakyThrows
public void onEmittedResource(ResourceHolder<GithubPullRequest> holder, ResourceEmitter<GithubPullRequest> emitter) {
    try (GithubPullRequest resource = holder.acquire()) {
        log.info("Received pull request " + resource.getPullRequest().getNumber());
        String sha = resource.getPullRequest().getHead().getSha();
        resource.getPullRequest().getRepository()
                .createCommitStatus(sha,
                                    GHCommitState.PENDING, configuration.getUrl() + "/ci/" + sha,
                                    "Build in progress", "cicomponents");
        Boolean result = new Builder(resource, outputProviderService).get();
        resource.getPullRequest().getRepository()
                .createCommitStatus(sha,
                                    result ? GHCommitState.SUCCESS : GHCommitState.FAILURE,
                                    configuration.getUrl() + "/ci/" + sha,
                                    result ? "Success" : "Failure", "cicomponents");
    }
}
 
开发者ID:cicomponents,项目名称:cicomponents,代码行数:25,代码来源:PullRequestListener.java

示例2: execute

import org.kohsuke.github.GHCommitState; //导入依赖的package包/类
@Override
public void execute(PostJobContext context) {
  GlobalReport report = new GlobalReport(markDownUtils, gitHubPluginConfiguration.tryReportIssuesInline());
  try {
    Map<InputFile, Map<Integer, StringBuilder>> commentsToBeAddedByLine = processIssues(report, context.issues());

    updateReviewComments(commentsToBeAddedByLine);

    pullRequestFacade.deleteOutdatedComments();

    pullRequestFacade.createOrUpdateGlobalComments(report.hasNewIssue() ? report.formatForMarkdown() : null);

    pullRequestFacade.createOrUpdateSonarQubeStatus(report.getStatus(), report.getStatusDescription());
  } catch (Exception e) {
    LOG.error("SonarQube analysis failed to complete the review of this pull request", e);
    pullRequestFacade.createOrUpdateSonarQubeStatus(GHCommitState.ERROR, StringUtils.abbreviate("SonarQube analysis failed: " + e.getMessage(), 140));
  }
}
 
开发者ID:SonarSource,项目名称:sonar-github,代码行数:19,代码来源:PullRequestIssuePostJob.java

示例3: testPullRequestAnalysisWithNewBlockerAndCriticalIssues

import org.kohsuke.github.GHCommitState; //导入依赖的package包/类
@Test
public void testPullRequestAnalysisWithNewBlockerAndCriticalIssues() throws MalformedURLException {
  DefaultInputFile inputFile1 = new DefaultInputFile("foo", "src/Foo.php");
  PostJobIssue newIssue = newMockedIssue("foo:src/Foo.php", inputFile1, 1, Severity.CRITICAL, true, "msg1");
  when(pullRequestFacade.getGithubUrl(inputFile1, 1)).thenReturn(new URL("http://github/blob/abc123/src/Foo.php#L1"));

  PostJobIssue lineNotVisible = newMockedIssue("foo:src/Foo.php", inputFile1, 2, Severity.BLOCKER, true, "msg2");
  when(pullRequestFacade.getGithubUrl(inputFile1, 2)).thenReturn(new URL("http://github/blob/abc123/src/Foo.php#L2"));

  when(context.issues()).thenReturn(Arrays.<PostJobIssue>asList(newIssue, lineNotVisible));
  when(pullRequestFacade.hasFile(inputFile1)).thenReturn(true);
  when(pullRequestFacade.hasFileLine(inputFile1, 1)).thenReturn(true);

  pullRequestIssuePostJob.execute(context);

  verify(pullRequestFacade).createOrUpdateSonarQubeStatus(GHCommitState.ERROR, "SonarQube reported 2 issues, with 1 critical and 1 blocker");
}
 
开发者ID:SonarSource,项目名称:sonar-github,代码行数:18,代码来源:PullRequestIssuePostJobTest.java

示例4: updateStatus

import org.kohsuke.github.GHCommitState; //导入依赖的package包/类
void updateStatus(GHCommitState status, StageExecution stageExecution) {
    ChainExecution chainExecution = stageExecution.getChainExecution();
    PlanResultKey planResultKey = chainExecution.getPlanResultKey();
    PlanKey planKey = planResultKey.getPlanKey();
    ImmutableChain chain = (ImmutableChain) planManager.getPlanByKey(planKey);

    for (RepositoryDefinition repo : Configuration.ghReposFrom(chain)) {
        if (shouldUpdateRepo(chain, repo)) {
            String sha = chainExecution.getBuildChanges().getVcsRevisionKey(repo.getId());
            if (sha != null) {
                GitHubRepository ghRepo = (GitHubRepository) repo.getRepository();
                setStatus(ghRepo, status, sha, planResultKey.getKey(), stageExecution.getName());
            }
        }
    }
}
 
开发者ID:HackAttack,项目名称:bamboo-github-status,代码行数:17,代码来源:AbstractGitHubStatusAction.java

示例5: updateStatus

import org.kohsuke.github.GHCommitState; //导入依赖的package包/类
@Override
public void updateStatus(String url, PluginSettings pluginSettings, String prIdStr, String revision, String pipelineStage,
                         String result, String trackbackURL) throws Exception {
    String repository = getRepository(url);
    GHCommitState state = getState(result);

    String endPointToUse = pluginSettings.getEndPoint();
    String usernameToUse = pluginSettings.getUsername();
    String passwordToUse = pluginSettings.getPassword();
    String oauthAccessTokenToUse = pluginSettings.getOauthToken();

    if (StringUtils.isEmpty(endPointToUse)) {
        endPointToUse = System.getProperty("go.plugin.build.status.github.endpoint");
    }
    if (StringUtils.isEmpty(usernameToUse)) {
        usernameToUse = System.getProperty("go.plugin.build.status.github.username");
    }
    if (StringUtils.isEmpty(passwordToUse)) {
        passwordToUse = System.getProperty("go.plugin.build.status.github.password");
    }
    if (StringUtils.isEmpty(oauthAccessTokenToUse)) {
        oauthAccessTokenToUse = System.getProperty("go.plugin.build.status.github.oauth");
    }

    updateCommitStatus(revision, pipelineStage, trackbackURL, repository, state, usernameToUse, passwordToUse, oauthAccessTokenToUse, endPointToUse);
}
 
开发者ID:gocd-contrib,项目名称:gocd-build-status-notifier,代码行数:27,代码来源:GitHubProvider.java

示例6: configure

import org.kohsuke.github.GHCommitState; //导入依赖的package包/类
@Override
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
    cron = formData.getString("cron");
    outputFile = formData.getString("outputFile");
    unstableAs = GHCommitState.valueOf(formData.getString("unstableAs"));
    autoCloseFailedPullRequests = formData.getBoolean("autoCloseFailedPullRequests");
    displayBuildErrorsOnDownstreamBuilds = formData.getBoolean("displayBuildErrorsOnDownstreamBuilds");
    
    githubAuth = req.bindJSONToList(GhprcGitHubAuth.class, formData.get("githubAuth"));
    
    extensions = new DescribableList<GhprcExtension, GhprcExtensionDescriptor>(Saveable.NOOP);

    try {
        extensions.rebuildHetero(req, formData, getGlobalExtensionDescriptors(), "extensions");
    } catch (IOException e) {
        e.printStackTrace();
    }
    
    readBackFromLegacy();

    save();
    return super.configure(req, formData);
}
 
开发者ID:bratchenko,项目名称:jenkins-github-pull-request-comments,代码行数:24,代码来源:GhprcTrigger.java

示例7: createCommitStatus

import org.kohsuke.github.GHCommitState; //导入依赖的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

示例8: postBuildComment

import org.kohsuke.github.GHCommitState; //导入依赖的package包/类
public String postBuildComment(AbstractBuild<?, ?> build, TaskListener listener) {
    
    StringBuilder msg = new StringBuilder();
    GHCommitState state = Ghprc.getState(build);

    int numLines = getLogExcerptLines();
    
    if (state != GHCommitState.SUCCESS && numLines > 0) {
        // on failure, append an excerpt of the build log
        try {
            // wrap log in "code" markdown
            msg.append("\n\n**Build Log**\n*last ").append(numLines).append(" lines*\n");
            msg.append("\n ```\n");
            List<String> log = build.getLog(numLines);
            for (String line : log) {
                msg.append(line).append('\n');
            }
            msg.append("```\n");
        } catch (IOException ex) {
            listener.getLogger().println("Can't add log excerpt to commit comments");
            ex.printStackTrace(listener.getLogger());
        }
    }
    return msg.toString();
}
 
开发者ID:bratchenko,项目名称:jenkins-github-pull-request-comments,代码行数:26,代码来源:GhprcBuildLog.java

示例9: commentOnFailure

import org.kohsuke.github.GHCommitState; //导入依赖的package包/类
public void commentOnFailure(AbstractBuild<?, ?> build, TaskListener listener, GhprcCommitStatusException ex) {
    PrintStream stream = null;
    if (listener != null) {
        stream = listener.getLogger();
    }
    GHCommitState state = ex.getState();
    Exception baseException = ex.getException();
    String newMessage;
    if (baseException instanceof FileNotFoundException) {
        newMessage = "FileNotFoundException means that the credentials Jenkins is using is probably wrong. Or the user account does not have write access to the repo.";
    } else {
        newMessage = "Could not update commit status of the Pull Request on GitHub.";
    }
    if (stream != null) {
        stream.println(newMessage);
        baseException.printStackTrace(stream);
    } else {
        logger.log(Level.INFO, newMessage, baseException);
    }
}
 
开发者ID:bratchenko,项目名称:jenkins-github-pull-request-comments,代码行数:21,代码来源:GhprcRepository.java

示例10: testMergedMessage

import org.kohsuke.github.GHCommitState; //导入依赖的package包/类
@Test
public void testMergedMessage() throws Exception {
    String mergedMessage = "Build triggered. sha1 is merged.";
    given(ghprcPullRequest.getHead()).willReturn("sha");
    given(ghprcPullRequest.isMergeable()).willReturn(true);

    GhprcSimpleStatus status = spy(new GhprcSimpleStatus("default"));
    status.onBuildTriggered(trigger, ghprcPullRequest, ghRepository);
    
    verify(ghRepository).createCommitStatus(eq("sha"), eq(GHCommitState.PENDING), isNull(String.class), eq(mergedMessage), eq("default"));
    verifyNoMoreInteractions(ghRepository);

    verify(ghprcPullRequest).getHead();
    verify(ghprcPullRequest).isMergeable();
    verifyNoMoreInteractions(ghprcPullRequest);
}
 
开发者ID:bratchenko,项目名称:jenkins-github-pull-request-comments,代码行数:17,代码来源:GhprcSimpleStatusTest.java

示例11: testMergeConflictMessage

import org.kohsuke.github.GHCommitState; //导入依赖的package包/类
@Test
public void testMergeConflictMessage() throws Exception {
    String mergedMessage = "Build triggered. sha1 is original commit.";
    given(ghprcPullRequest.getHead()).willReturn("sha");
    given(ghprcPullRequest.isMergeable()).willReturn(false);

    GhprcSimpleStatus status = spy(new GhprcSimpleStatus("default"));
    status.onBuildTriggered(trigger, ghprcPullRequest, ghRepository);
    
    verify(ghRepository).createCommitStatus(eq("sha"), eq(GHCommitState.PENDING), isNull(String.class), eq(mergedMessage), eq("default"));
    verifyNoMoreInteractions(ghRepository);

    verify(ghprcPullRequest).getHead();
    verify(ghprcPullRequest).isMergeable();
    verifyNoMoreInteractions(ghprcPullRequest);
}
 
开发者ID:bratchenko,项目名称:jenkins-github-pull-request-comments,代码行数:17,代码来源:GhprcSimpleStatusTest.java

示例12: testDoesNotSendEmptyContext

import org.kohsuke.github.GHCommitState; //导入依赖的package包/类
@Test
public void testDoesNotSendEmptyContext() throws Exception {
    String mergedMessage = "Build triggered. sha1 is original commit.";
    given(ghprcPullRequest.getHead()).willReturn("sha");
    given(ghprcPullRequest.isMergeable()).willReturn(false);

    GhprcSimpleStatus status = spy(new GhprcSimpleStatus(""));
    status.onBuildTriggered(trigger, ghprcPullRequest, ghRepository);
    
    verify(ghRepository).createCommitStatus(eq("sha"), eq(GHCommitState.PENDING), isNull(String.class), eq(mergedMessage), isNull(String.class));
    verifyNoMoreInteractions(ghRepository);

    verify(ghprcPullRequest).getHead();
    verify(ghprcPullRequest).isMergeable();
    verifyNoMoreInteractions(ghprcPullRequest);
}
 
开发者ID:bratchenko,项目名称:jenkins-github-pull-request-comments,代码行数:17,代码来源:GhprcSimpleStatusTest.java

示例13: build

import org.kohsuke.github.GHCommitState; //导入依赖的package包/类
@Override
public void build(Context context) {
  if (!gitHubPluginConfiguration.isEnabled()) {
    return;
  }
  checkMode();
  int pullRequestNumber = gitHubPluginConfiguration.pullRequestNumber();
  pullRequestFacade.init(pullRequestNumber, context.projectReactor().getRoot().getBaseDir());

  pullRequestFacade.createOrUpdateSonarQubeStatus(GHCommitState.PENDING, "SonarQube analysis in progress");
}
 
开发者ID:SonarSource,项目名称:sonar-github,代码行数:12,代码来源:PullRequestProjectBuilder.java

示例14: testPullRequestAnalysisNoIssue

import org.kohsuke.github.GHCommitState; //导入依赖的package包/类
@Test
public void testPullRequestAnalysisNoIssue() {
  when(context.issues()).thenReturn(Arrays.<PostJobIssue>asList());
  pullRequestIssuePostJob.execute(context);
  verify(pullRequestFacade).createOrUpdateGlobalComments(null);
  verify(pullRequestFacade).createOrUpdateSonarQubeStatus(GHCommitState.SUCCESS, "SonarQube reported no issues");
}
 
开发者ID:SonarSource,项目名称:sonar-github,代码行数:8,代码来源:PullRequestIssuePostJobTest.java

示例15: testPullRequestAnalysisWithNewIssues

import org.kohsuke.github.GHCommitState; //导入依赖的package包/类
@Test
public void testPullRequestAnalysisWithNewIssues() throws MalformedURLException {
  DefaultInputFile inputFile1 = new DefaultInputFile("foo", "src/Foo.php");
  PostJobIssue newIssue = newMockedIssue("foo:src/Foo.php", inputFile1, 1, Severity.BLOCKER, true, "msg1");
  when(pullRequestFacade.getGithubUrl(inputFile1, 1)).thenReturn(new URL("http://github/blob/abc123/src/Foo.php#L1"));

  PostJobIssue lineNotVisible = newMockedIssue("foo:src/Foo.php", inputFile1, 2, Severity.BLOCKER, true, "msg2");
  when(pullRequestFacade.getGithubUrl(inputFile1, 2)).thenReturn(new URL("http://github/blob/abc123/src/Foo.php#L2"));

  DefaultInputFile inputFile2 = new DefaultInputFile("foo", "src/Foo2.php");
  PostJobIssue fileNotInPR = newMockedIssue("foo:src/Foo2.php", inputFile2, 1, Severity.BLOCKER, true, "msg3");

  PostJobIssue notNewIssue = newMockedIssue("foo:src/Foo.php", inputFile1, 1, Severity.BLOCKER, false, "msg");

  PostJobIssue issueOnDir = newMockedIssue("foo:src", Severity.BLOCKER, true, "msg4");

  PostJobIssue issueOnProject = newMockedIssue("foo", Severity.BLOCKER, true, "msg");

  PostJobIssue globalIssue = newMockedIssue("foo:src/Foo.php", inputFile1, null, Severity.BLOCKER, true, "msg5");

  when(context.issues()).thenReturn(Arrays.<PostJobIssue>asList(newIssue, globalIssue, issueOnProject, issueOnDir, fileNotInPR, lineNotVisible, notNewIssue));
  when(pullRequestFacade.hasFile(inputFile1)).thenReturn(true);
  when(pullRequestFacade.hasFileLine(inputFile1, 1)).thenReturn(true);

  pullRequestIssuePostJob.execute(context);
  verify(pullRequestFacade).createOrUpdateGlobalComments(contains("SonarQube analysis reported 5 issues"));
  verify(pullRequestFacade)
    .createOrUpdateGlobalComments(contains("* ![BLOCKER][BLOCKER] 5 blocker"));
  verify(pullRequestFacade)
    .createOrUpdateGlobalComments(
      not(contains("1. [Project")));
  verify(pullRequestFacade)
    .createOrUpdateGlobalComments(
      contains(
        "1. ![BLOCKER][BLOCKER] [Foo.php#L2](http://github/blob/abc123/src/Foo.php#L2): msg2 [![rule](https://sonarsource.github.io/sonar-github/rule.png)](http://myserver/coding_rules#rule_key=repo%3Arule)"));

  verify(pullRequestFacade).createOrUpdateSonarQubeStatus(GHCommitState.ERROR, "SonarQube reported 5 issues, with 5 blocker");
}
 
开发者ID:SonarSource,项目名称:sonar-github,代码行数:39,代码来源:PullRequestIssuePostJobTest.java


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