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());
    }
  }
 public void onBuildStart(AbstractBuild<?, ?> build, TaskListener listener, GHRepository repo)
     throws GhprcCommitStatusException {
   GhprcCause c = Ghprc.getCause(build);
   StringBuilder sb = new StringBuilder();
   if (StringUtils.isEmpty(startedStatus)) {
     sb.append("Build started");
     sb.append(c.isMerged() ? " sha1 is merged." : " sha1 is original commit.");
   } else {
     sb.append(Ghprc.replaceMacros(build, listener, startedStatus));
   }
   createCommitStatus(build, listener, sb.toString(), repo, GHCommitState.PENDING);
 }