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

Add option to choose static notification context

      Commit https://github.com/jenkinsci/github-branch-source-plugin/commit/5a98d2a885aa951087ba329acdc560bc1e6b7062 just broke the workflow for us.

      We have our protected branches set up to check for context "Jenkins", so a successful build (from our organisation/multibranch projects) is enforced before merging. Through the mentioned commit, we now get "Jenkins job <whatever>" as notification context, on which we cannot protect anymore.

      Please add an option to choose if the default context should contain the job name or not.
      I am aware that you can set a custom context through the GitHubCommitStatusSetter step, but its not a viable and clean solution for us, as we would have to change hundreds of Jenkinsfiles.

          [JENKINS-36574] Add option to choose static notification context

          Jesse Glick added a comment -

          FTR the reason for the change is that it is now possible to have two jobs building the same PR in different ways.

          Jesse Glick added a comment - FTR the reason for the change is that it is now possible to have two jobs building the same PR in different ways.

          Jesse Glick added a comment -

          …which would suggest a possible solution of changing the context to not mention the job name, but to vary according to whether or not this is a merging job.

          Jesse Glick added a comment - …which would suggest a possible solution of changing the context to not mention the job name, but to vary according to whether or not this is a merging job.

          Hans Schulz added a comment -

          I don't see why having two jobs building the same PR would not have been possible before, since you can always use the GitHubCommitStatusSetter step to set a different status context.

          Hans Schulz added a comment - I don't see why having two jobs building the same PR would not have been possible before, since you can always use the GitHubCommitStatusSetter step to set a different status context.

          I have to agree - please keep the status constant.
          https://issues.jenkins-ci.org/browse/JENKINS-36602

          Thomas Müller added a comment - I have to agree - please keep the status constant. https://issues.jenkins-ci.org/browse/JENKINS-36602

          Thomas Müller added a comment - Here is a pr to revert the change https://github.com/jenkinsci/github-branch-source-plugin/pull/62

          Kevin Brown added a comment -

          I can see the use in having a different status context for different builds, and I am also running into the problem of protected branches and not having the same status name (so they can no longer be protected).

          Would an acceptable middle ground be a configuration option for setting the status context? Something which would allow for the job name to be included as a variable, so people could remove it if they don't need it.

          Kevin Brown added a comment - I can see the use in having a different status context for different builds, and I am also running into the problem of protected branches and not having the same status name (so they can no longer be protected). Would an acceptable middle ground be a configuration option for setting the status context? Something which would allow for the job name to be included as a variable, so people could remove it if they don't need it.

          Nick Jones added a comment - - edited

          As I also commented on the proposed above PR, my specific problem with original change is its impact on our use of GitHub Organization Folders. In that scenario, the only name under my direct control on the Jenkins side is the name of the folder (New Item > GitHub Organization); the jobs/folders within that folder are created dynamically (based on GH repositories in the specified organization that have Jenkinsfiles) and the jobs underneath those are created dynamically based on branches or PRs that exist within the repo. So, when configuring branch protection, where I previously could count on "Jenkins" as the status check to require, the current job name-based status checks ("Jenkins job jobname") are useless – I can't know them ahead of time.

          So, what I'd want is for the GitHub Branch Source plugin to take an override when used specifically within the GitHub Organization Folder plugin such that its statuses would be based on the folder name (e.g., "Jenkins foldername"). I get the value of not having it be simply "Jenkins" all the time (for different jobs doing different builds of the same repo), but it needs to be something I can establish and count on either in Jenkins or in the Jenkinsfiles, and I'd prefer the former.

          Nick Jones added a comment - - edited As I also commented on the proposed above PR, my specific problem with original change is its impact on our use of GitHub Organization Folders. In that scenario, the only name under my direct control on the Jenkins side is the name of the folder (New Item > GitHub Organization); the jobs/folders within that folder are created dynamically (based on GH repositories in the specified organization that have Jenkinsfiles) and the jobs underneath those are created dynamically based on branches or PRs that exist within the repo. So, when configuring branch protection, where I previously could count on "Jenkins" as the status check to require, the current job name-based status checks ("Jenkins job jobname ") are useless – I can't know them ahead of time. So, what I'd want is for the GitHub Branch Source plugin to take an override when used specifically within the GitHub Organization Folder plugin such that its statuses would be based on the folder name (e.g., "Jenkins foldername "). I get the value of not having it be simply "Jenkins" all the time (for different jobs doing different builds of the same repo), but it needs to be something I can establish and count on either in Jenkins or in the Jenkinsfiles, and I'd prefer the former.

          Nick Jones added a comment -

          Looking into this further, I'd suggest taking a page from how AppVeyor and Travis CI (and probably others) handle this, which is a status that categorizes the type of thing being built, e.g.:

          • continuous-integration/appveyor/branch
          • continuous-integration/appveyor/pr

          See http://help.appveyor.com/discussions/suggestions/798-split-build-status-on-github-pr and https://github.com/travis-ci/travis-tasks/pull/31. In our case, something like:

          • continuous-integration/jenkins/branch
          • continuous-integration/jenkins/pr

          How does that sound?

          Nick Jones added a comment - Looking into this further, I'd suggest taking a page from how AppVeyor and Travis CI (and probably others) handle this, which is a status that categorizes the type of thing being built, e.g.: continuous-integration/appveyor/branch continuous-integration/appveyor/pr See http://help.appveyor.com/discussions/suggestions/798-split-build-status-on-github-pr and https://github.com/travis-ci/travis-tasks/pull/31 . In our case, something like: continuous-integration/jenkins/branch continuous-integration/jenkins/pr How does that sound?

          The option to change to a dynamic context string aggravates the problem of not being able to disable the default SCM commit status. If you could disable it, Pipeline authors could easily choose to use either a static or varied context string via GitHubCommitStatusSetter.

          Protected branches are not the only thing out there that assumes the number of commit status context strings will be low across an entire project. (This current implementation will create 100 contexts for 100 branches if you're doing GithubFlow; and that prevents Jenkins Pipeline users from taking advantage of the entire ecosystem of Github integrations that use the context strings normally.)

          Dominic Scheirlinck added a comment - The option to change to a dynamic context string aggravates the problem of not being able to disable the default SCM commit status. If you could disable it, Pipeline authors could easily choose to use either a static or varied context string via GitHubCommitStatusSetter. Protected branches are not the only thing out there that assumes the number of commit status context strings will be low across an entire project. (This current implementation will create 100 contexts for 100 branches if you're doing GithubFlow; and that prevents Jenkins Pipeline users from taking advantage of the entire ecosystem of Github integrations that use the context strings normally.)

          Heh. I didn't find this when searching originally, in part because I didn't know what was causing this problem. So I filed JENKINS-37100 about this.

          I think medianick's suggestion is the right one. I'll see if I can figure it out how to do a pull request for that.

          Christian Höltje added a comment - Heh. I didn't find this when searching originally, in part because I didn't know what was causing this problem. So I filed JENKINS-37100 about this. I think medianick 's suggestion is the right one. I'll see if I can figure it out how to do a pull request for that.

          I pushed up a Pull Request that sets the context to one of:

          • continuous-integration/jenkins/pr
          • continuous-integration/jenkins/branch

          It's hacky (it looks at job.getName() to figure out if it is a PR or not) because I couldn't figure out a better way to detect if it is a PR or not.

          Christian Höltje added a comment - I pushed up a Pull Request that sets the context to one of: continuous-integration/jenkins/pr continuous-integration/jenkins/branch It's hacky (it looks at job.getName() to figure out if it is a PR or not) because I couldn't figure out a better way to detect if it is a PR or not.

          Julien Maitrehenry added a comment - - edited

          I really like this solution, but is it possible, in an another version to be able to configure continuous-integration/jenkins?
          It's a nice feature when you migrate from one jenkins to another and don't want to mix the status check on Github.

          Julien Maitrehenry added a comment - - edited I really like this solution, but is it possible, in an another version to be able to configure continuous-integration/jenkins ? It's a nice feature when you migrate from one jenkins to another and don't want to mix the status check on Github.

          I barely know enough Java to do what I did.

          Ideally I would want to be able to replace the jenkins with something identifying what Jenkins. e.g. automan

          But that'd require understanding Jelly, etc.

          Christian Höltje added a comment - I barely know enough Java to do what I did. Ideally I would want to be able to replace the jenkins with something identifying what Jenkins. e.g. automan But that'd require understanding Jelly, etc.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubBuildStatusNotification.java
          http://jenkins-ci.org/commit/github-branch-source-plugin/d9fbd745c15ccd4cde1be0bd9e97be1f1a86dcb5
          Log:
          [FIXED JENKINS-36574] Use the minimum number of status contexts necessary to differentiate jobs potentially building a given commit.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubBuildStatusNotification.java http://jenkins-ci.org/commit/github-branch-source-plugin/d9fbd745c15ccd4cde1be0bd9e97be1f1a86dcb5 Log: [FIXED JENKINS-36574] Use the minimum number of status contexts necessary to differentiate jobs potentially building a given commit.

          Eike Waldt added a comment -

          Julien Maitrehenry: "[..] but is it possible, in an another version to be able to configure continuous-integration/jenkins?
          It's a nice feature when you migrate from one jenkins to another and don't want to mix the status check on Github."

          https://github.com/jenkinsci/github-branch-source-plugin/pull/88 implements a configurable "continuous-integration/jenkins".
          It makes it also possible to run 2 jenkins instances on the same github repo/Organisation.

          Eike Waldt added a comment - Julien Maitrehenry: " [..] but is it possible, in an another version to be able to configure continuous-integration/jenkins? It's a nice feature when you migrate from one jenkins to another and don't want to mix the status check on Github." https://github.com/jenkinsci/github-branch-source-plugin/pull/88 implements a configurable "continuous-integration/jenkins". It makes it also possible to run 2 jenkins instances on the same github repo/Organisation.

          Eike Waldt added a comment -

          https://github.com/jenkinsci/github-branch-source-plugin/pull/138 was just opened to address this issue again,

          Eike Waldt added a comment - https://github.com/jenkinsci/github-branch-source-plugin/pull/138 was just opened to address this issue again,

          Jesse Glick added a comment -

          yeoldegrove please do not reopen. You may file separate issues (and link them) for related concerns.

          Jesse Glick added a comment - yeoldegrove please do not reopen. You may file separate issues (and link them) for related concerns.

          Code changed in jenkins
          User: Stephen Connolly
          Path:
          src/test/java/org/jenkinsci/plugins/github_branch_source/DefaultGitHubNotificationStrategyTest.java
          http://jenkins-ci.org/commit/github-branch-source-plugin/a35c612015bd17d38a66786e8c9233b14e47f7e0
          Log:
          JENKINS-36574 And example stub test

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Stephen Connolly Path: src/test/java/org/jenkinsci/plugins/github_branch_source/DefaultGitHubNotificationStrategyTest.java http://jenkins-ci.org/commit/github-branch-source-plugin/a35c612015bd17d38a66786e8c9233b14e47f7e0 Log: JENKINS-36574 And example stub test

          Code changed in jenkins
          User: steven-foster
          Path:
          .gitignore
          pom.xml
          src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMBuilder.java
          src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMFile.java
          src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMFileSystem.java
          src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java
          src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMProbe.java
          src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java
          src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceRequest.java
          src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubTagSCMHead.java
          src/main/java/org/jenkinsci/plugins/github_branch_source/PullRequestAction.java
          src/main/java/org/jenkinsci/plugins/github_branch_source/PullRequestGHEventSubscriber.java
          src/main/java/org/jenkinsci/plugins/github_branch_source/PushGHEventSubscriber.java
          src/main/java/org/jenkinsci/plugins/github_branch_source/TagDiscoveryTrait.java
          src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties
          src/main/resources/org/jenkinsci/plugins/github_branch_source/TagDiscoveryTrait/config.jelly
          src/main/resources/org/jenkinsci/plugins/github_branch_source/TagDiscoveryTrait/help.html
          src/test/java/org/jenkinsci/plugins/github_branch_source/TagDiscoveryTraitTest.java
          http://jenkins-ci.org/commit/github-branch-source-plugin/51e1535a7f6eb7264d59ba900c4e337443b51620
          Log:
          Merge branch 'master' into JENKINS-36574

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: steven-foster Path: .gitignore pom.xml src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMBuilder.java src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMFile.java src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMFileSystem.java src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMProbe.java src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceRequest.java src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubTagSCMHead.java src/main/java/org/jenkinsci/plugins/github_branch_source/PullRequestAction.java src/main/java/org/jenkinsci/plugins/github_branch_source/PullRequestGHEventSubscriber.java src/main/java/org/jenkinsci/plugins/github_branch_source/PushGHEventSubscriber.java src/main/java/org/jenkinsci/plugins/github_branch_source/TagDiscoveryTrait.java src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties src/main/resources/org/jenkinsci/plugins/github_branch_source/TagDiscoveryTrait/config.jelly src/main/resources/org/jenkinsci/plugins/github_branch_source/TagDiscoveryTrait/help.html src/test/java/org/jenkinsci/plugins/github_branch_source/TagDiscoveryTraitTest.java http://jenkins-ci.org/commit/github-branch-source-plugin/51e1535a7f6eb7264d59ba900c4e337443b51620 Log: Merge branch 'master' into JENKINS-36574

          Code changed in jenkins
          User: Stephen Connolly
          Path:
          docs/implementation.adoc
          src/main/java/org/jenkinsci/plugins/github_branch_source/AbstractGitHubNotificationStrategy.java
          src/main/java/org/jenkinsci/plugins/github_branch_source/DefaultGitHubNotificationStrategy.java
          src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubBuildStatusNotification.java
          src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubNotificationContext.java
          src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubNotificationRequest.java
          src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceContext.java
          src/test/java/org/jenkinsci/plugins/github_branch_source/DefaultGitHubNotificationStrategyTest.java
          src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubNotificationTest.java
          http://jenkins-ci.org/commit/github-branch-source-plugin/267e41c5958116d58543018bdc81ff98ef0867fa
          Log:
          Merge pull request #162 from steven-foster/JENKINS-36574

          JENKINS-36574 Custom Github status context

          Compare: https://github.com/jenkinsci/github-branch-source-plugin/compare/e8c6c778f3aa...267e41c59581

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Stephen Connolly Path: docs/implementation.adoc src/main/java/org/jenkinsci/plugins/github_branch_source/AbstractGitHubNotificationStrategy.java src/main/java/org/jenkinsci/plugins/github_branch_source/DefaultGitHubNotificationStrategy.java src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubBuildStatusNotification.java src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubNotificationContext.java src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubNotificationRequest.java src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceContext.java src/test/java/org/jenkinsci/plugins/github_branch_source/DefaultGitHubNotificationStrategyTest.java src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubNotificationTest.java http://jenkins-ci.org/commit/github-branch-source-plugin/267e41c5958116d58543018bdc81ff98ef0867fa Log: Merge pull request #162 from steven-foster/ JENKINS-36574 JENKINS-36574 Custom Github status context Compare: https://github.com/jenkinsci/github-branch-source-plugin/compare/e8c6c778f3aa...267e41c59581

            jglick Jesse Glick
            schulzha Hans Schulz
            Votes:
            12 Vote for this issue
            Watchers:
            21 Start watching this issue

              Created:
              Updated:
              Resolved: