Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-37100

GitHub status check "context" should be constant

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • None
    • Jenkins: 2.7.1
      github-api.jpi v1.76
      github-branch-source.jpi v1.8.1
      github-oauth.jpi v0.24
      github-organization-folder.jpi v1.4
      github.jpi v1.20.0

      When doing a pull request, the github PR page is updated with a status check showing the progress or result of a Jenkins build.

      Currently, the name for the status looks something like Jenkins job PR-1. In the github api docs, they call this the "context".

      The problem is that the "context" changes for each PR and branch. This makes setting up protections for branches impossible.

      If you turn on protections for a branch and then go to https://github.com/my-org/my-project/settings/branches/my-branch and turn on "Require status checks to pass before merging" you'll be shown "Status checks found in the last week for this repository" which might include (for example):

      • Jenkins job PR-1
      • Jenkins job PR-2
      • Jenkins job master

      You can't require any of these status checks because the next status check will have a context with a new (previously unseen) PR number.

      Instead, it should just say "Jenkins" or a customized name specified in the default branch's Jenkinsfile.

          [JENKINS-37100] GitHub status check "context" should be constant

          It looks like this Jenkinsfile snippet is supposed to change the status check "context" name but it doesn't work if using the github-organization-folder plugin:

          properties([
                  [$class: 'GithubProjectProperty', displayName: 'STATICNAME', projectUrlStr: 'https://github.com/<my-org>/<my-project>']
          ]);
          

          So I guess this is a bug in the github-organization-folder plugin?

          Christian Höltje added a comment - It looks like this Jenkinsfile snippet is supposed to change the status check "context" name but it doesn't work if using the github-organization-folder plugin: properties([ [$class: 'GithubProjectProperty' , displayName: 'STATICNAME' , projectUrlStr: 'https: //github.com/<my-org>/<my-project>' ] ]); So I guess this is a bug in the github-organization-folder plugin?

          I think I found the source of the problem in the github-branch-source-plugin:...GitHubBuildStatusNotification.java:73.

          It seems like it should be replaced with something like:

              private static void createCommitStatus(@Nonnull GHRepository repo, @Nonnull String revision, @Nonnull GHCommitState state, @Nonnull String url, @Nonnull String message, @Nonnull Job<?,?> job) throws IOException {
                  LOGGER.log(Level.FINE, "{0}/commit/{1} {2} from {3}", new Object[] {repo.getHtmlUrl(), revision, state, url});
                  repo.createCommitStatus(revision, state, url, message, "Jenkins job " + job.getParent().getName());
              }
          

          I added getParent() so that the context name would become "Jenkins job <folder name>" instead of "Jenkins job <branch-name-or-pr-name>".

          Christian Höltje added a comment - I think I found the source of the problem in the github-branch-source-plugin:...GitHubBuildStatusNotification.java:73 . It seems like it should be replaced with something like: private static void createCommitStatus(@Nonnull GHRepository repo, @Nonnull String revision, @Nonnull GHCommitState state, @Nonnull String url, @Nonnull String message, @Nonnull Job<?,?> job) throws IOException { LOGGER.log(Level.FINE, "{0}/commit/{1} {2} from {3}" , new Object [] {repo.getHtmlUrl(), revision, state, url}); repo.createCommitStatus(revision, state, url, message, "Jenkins job " + job.getParent().getName()); } I added getParent() so that the context name would become "Jenkins job <folder name>" instead of "Jenkins job <branch-name-or-pr-name>".

          Christian Höltje added a comment - Ah, I found some comments on this on https://github.com/jenkinsci/github-branch-source-plugin/commit/5a98d2a885aa951087ba329acdc560bc1e6b7062 and a duplicate issue https://issues.jenkins-ci.org/browse/JENKINS-36574 .

          Does anyone know if there is a workaround to fix this until a solution is found?

          Kaden Wilkinson added a comment - Does anyone know if there is a workaround to fix this until a solution is found?

            lanwen Kirill Merkushev
            docwhat Christian Höltje
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: