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());
    }
  }
  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());
    }
  }