github-plugin icon indicating copy to clipboard operation
github-plugin copied to clipboard

[JENKINS-75789] organization folder with github project provider missing "GitHub hook trigger for GITScm polling ?" frontend

Open jenkins-infra-bot opened this issue 6 months ago • 1 comments

as a jenkins administrator, and github administrator
i want my team to have access to rapid rebuilds in response to github events,
and i want my jenkins config to have minimal project-wise config to greater enable my team to introduce new projects with low overhead.
for example by integrating via github webhooks to jenkins's github organization folder project provider.

consider the difference between these two jobs.

  • First, a freestyle project with "Triggers -> GitHub hook trigger for GITScm polling?" enabled.
  • Second, a organization project folder with a github provider. There is no config gui section for triggers, and the only trigger option is a periodic scan cron.

Note: job triggered were dumped with this groovy script at the jenkins script console.
```

def jobFullName = "My Freestyle Projects/my-project"
//def jobFullName = "My Github Org/my-project"

// Get the Jenkins instance and the job
def job = Jenkins.instance.getItemByFullName(jobFullName)

if (job == null) {
    println "Job not found: ${jobFullName}"
    return
}

// Get triggers from the job definition
def triggers = job.getTriggers()

if (triggers.isEmpty()) {
    println "No triggers found for job: ${jobFullName}"
} else {
    println "Triggers for job '${jobFullName}':"
    triggers.each { triggerType, trigger ->
        println "- ${triggerType}: ${trigger}"
    }
}
```

First the freestyle project, including a `com.cloudbees.jenkins.GitHubPushTrigger` trigger:

`def jobFullName = "My Freestyle Projects/my project"`
```
Triggers for job 'My Freestyle Projects/my project push test': - com.cloudbees.jenkins.GitHubPushTrigger$DescriptorImpl@​2bd4b183: com.cloudbees.jenkins.GitHubPushTrigger@​376a03ca[] Result: {com.cloudbees.jenkins.GitHubPushTrigger$DescriptorImpl@​2bd4b183=com.cloudbees.jenkins.GitHubPushTrigger@​376a03ca[]}
```

Second, the organization project, it includes only `com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger` triggers.

`def jobFullName = "My Github Org/my-project"`
```
Triggers for job 'My Github Org/my-project': - com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger$DescriptorImpl@​363e5fee: com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger@​1be9ee91[H H/4 * * *] Result: {com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger$DescriptorImpl@​363e5fee=com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger@​1be9ee91[H H/4 * * *]}
```

I think this is an implementation bug.
By my reading of the soruce code here
https://github.com/jenkinsci/github-plugin/blob/0c86f968d0aa157c74fcd8b6477095ab1aab0883/src/main/java/org/jenkinsci/plugins/github/webhook/subscriber/DefaultPushGHEventSubscriber.java#L89-L90
it seems clear that the webhook secton of this plugin is purpose-built to scan all jenkins jobs and trigger builds where the job logical scm tuple from example `git@​github.com/mygithuborg/myrepo.git` converts to `("github.com", "mygithuborg", "myrepo")` matches a github webhook with an html url for example `https://github.com/mygithuborg/myrepo` converts to (`"github.com", "mygithuborg", "myrepo")`

it appears this match would test positive in my case but when capturing logs, the last log emission from the delivered github webhook is 
https://github.com/jenkinsci/github-plugin/blob/0c86f968d0aa157c74fcd8b6477095ab1aab0883/src/main/java/com/cloudbees/jenkins/GitHubRepositoryName.java#L82

suggesting that the only code path that this sample could have followed is the path where the trigger of type `com.cloudbees.jenkins.GitHubPushTrigger` was missing from the jobs. and I clarified that this is in fact the case earlier.

so what remains is a path forward.

I checked and by my thorough examination, there is no built in configuration option for a organization project folder using the github project project provider to elect to auto-configure com.cloudbees.jenkins.GitHubPushTrigger triggers for all jobs.

I imagine it's possible for me to install these jobs by hand, however i fear that any reconfiguration of the github project provider might wipe out these configurations, as well as the lack of a ui to exemplify that this option is on and must be checked to gain this feature seems both fragile and unhelpful for long-term operation.

pseudo-code follows, the following may exemplify the enrollment of github webhook triggers on a project folder
```

import com.cloudbees.jenkins.GitHubPushTrigger
import jenkins.model.Jenkins

// The name of the organization project folder
def folderName = "foo"

// Get the folder item
def folder = Jenkins.instance.getItemByFullName(folderName)
if (!(folder instanceof com.cloudbees.hudson.plugins.folder.Folder)) {
    println "Item '${folderName}' is not a folder or doesn't exist."
    return
}

// Iterate over all jobs in the folder
folder.getAllJobs().each { job ->
    // Skip if it's not a job that can have triggers
    if (!job.hasProperty("triggers")) {
        println "Skipping non-job item: ${job.fullName}"
        return
    }

    // Check if GitHubPushTrigger is already configured
    def existing = job.getTriggers().get(GitHubPushTrigger.class)
    if (existing != null) {
        println "Already has GitHubPushTrigger: ${job.fullName}"
        return
    }

    // Add the GitHubPushTrigger
    println "Adding GitHubPushTrigger to: ${job.fullName}"
    job.addTrigger(new GitHubPushTrigger()) // THIS IS PSEUDO CODE
    job.save()
}
```

I hope that the change to enroll a new organization folder github project provider setting to enable this already-coded feature is a minimal change and fits the github plugin design goals.


Originally reported by dylan_at_shipwell_dot_com, imported from: organization folder with github project provider missing "GitHub hook trigger for GITScm polling ?" frontend
  • assignee: lanwen
  • status: Open
  • priority: Minor
  • component(s): github-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 2025-12-08
Raw content of original issue

as a jenkins administrator, and github administrator i want my team to have access to rapid rebuilds in response to github events, and i want my jenkins config to have minimal project-wise config to greater enable my team to introduce new projects with low overhead. for example by integrating via github webhooks to jenkins's github organization folder project provider.

consider the difference between these two jobs.

  • First, a freestyle project with "Triggers -> GitHub hook trigger for GITScm polling?" enabled.
  • Second, a organization project folder with a github provider. There is no config gui section for triggers, and the only trigger option is a periodic scan cron.

Note: job triggered were dumped with this groovy script at the jenkins script console. ```

def jobFullName = "My Freestyle Projects/my-project" //def jobFullName = "My Github Org/my-project"

// Get the Jenkins instance and the job def job = Jenkins.instance.getItemByFullName(jobFullName)

if (job == null) {     println "Job not found: ${jobFullName}"     return }

// Get triggers from the job definition def triggers = job.getTriggers()

if (triggers.isEmpty()) {     println "No triggers found for job: ${jobFullName}" } else {     println "Triggers for job '${jobFullName}':"     triggers.each { triggerType, trigger ->         println "- ${triggerType}: ${trigger}"     } } ```

First the freestyle project, including a `com.cloudbees.jenkins.GitHubPushTrigger` trigger:

`def jobFullName = "My Freestyle Projects/my project"` ``` Triggers for job 'My Freestyle Projects/my project push test': - com.cloudbees.jenkins.GitHubPushTrigger$DescriptorImpl@2bd4b183: com.cloudbees.jenkins.GitHubPushTrigger@376a03ca[] Result: {com.cloudbees.jenkins.GitHubPushTrigger$DescriptorImpl@2bd4b183=com.cloudbees.jenkins.GitHubPushTrigger@376a03ca[]} ```

Second, the organization project, it includes only `com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger` triggers.

`def jobFullName = "My Github Org/my-project"` ``` Triggers for job 'My Github Org/my-project': - com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger$DescriptorImpl@363e5fee: com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger@1be9ee91[H H/4 * * *] Result: {com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger$DescriptorImpl@363e5fee=com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger@1be9ee91[H H/4 * * *]} ```

I think this is an implementation bug. By my reading of the soruce code here https://github.com/jenkinsci/github-plugin/blob/0c86f968d0aa157c74fcd8b6477095ab1aab0883/src/main/java/org/jenkinsci/plugins/github/webhook/subscriber/DefaultPushGHEventSubscriber.java#L89-L90 it seems clear that the webhook secton of this plugin is purpose-built to scan all jenkins jobs and trigger builds where the job logical scm tuple from example `[email protected]/mygithuborg/myrepo.git` converts to `("github.com", "mygithuborg", "myrepo")` matches a github webhook with an html url for example `https://github.com/mygithuborg/myrepo` converts to (`"github.com", "mygithuborg", "myrepo")`

it appears this match would test positive in my case but when capturing logs, the last log emission from the delivered github webhook is  https://github.com/jenkinsci/github-plugin/blob/0c86f968d0aa157c74fcd8b6477095ab1aab0883/src/main/java/com/cloudbees/jenkins/GitHubRepositoryName.java#L82

suggesting that the only code path that this sample could have followed is the path where the trigger of type `com.cloudbees.jenkins.GitHubPushTrigger` was missing from the jobs. and I clarified that this is in fact the case earlier.

so what remains is a path forward.

I checked and by my thorough examination, there is no built in configuration option for a organization project folder using the github project project provider to elect to auto-configure com.cloudbees.jenkins.GitHubPushTrigger triggers for all jobs.

I imagine it's possible for me to install these jobs by hand, however i fear that any reconfiguration of the github project provider might wipe out these configurations, as well as the lack of a ui to exemplify that this option is on and must be checked to gain this feature seems both fragile and unhelpful for long-term operation.

pseudo-code follows, the following may exemplify the enrollment of github webhook triggers on a project folder ```

import com.cloudbees.jenkins.GitHubPushTrigger import jenkins.model.Jenkins

// The name of the organization project folder def folderName = "foo"

// Get the folder item def folder = Jenkins.instance.getItemByFullName(folderName) if (!(folder instanceof com.cloudbees.hudson.plugins.folder.Folder)) {     println "Item '${folderName}' is not a folder or doesn't exist."     return }

// Iterate over all jobs in the folder folder.getAllJobs().each { job ->     // Skip if it's not a job that can have triggers     if (!job.hasProperty("triggers")) {         println "Skipping non-job item: ${job.fullName}"         return     }

    // Check if GitHubPushTrigger is already configured     def existing = job.getTriggers().get(GitHubPushTrigger.class)     if (existing != null) {         println "Already has GitHubPushTrigger: ${job.fullName}"         return     }

    // Add the GitHubPushTrigger     println "Adding GitHubPushTrigger to: ${job.fullName}"     job.addTrigger(new GitHubPushTrigger()) // THIS IS PSEUDO CODE     job.save() } ```

I hope that the change to enroll a new organization folder github project provider setting to enable this already-coded feature is a minimal change and fits the github plugin design goals.

jenkins-infra-bot avatar Jun 17 '25 22:06 jenkins-infra-bot

dylan_at_shipwell_dot_com:
  • Original comment link
  • Raw content of original comment:

    it's possible i still don't understand the code well enough. in my case, i have "My Freestyle Projects/my-project" with triggers {com.cloudbees.jenkins.GitHubPushTrigger$DescriptorImpl@2bd4b183=com.cloudbees.jenkins.GitHubPushTrigger@376a03ca[]}

    repeat-delivery of the webhook i thought triggerd it doesn't re-trigger it.

    my com.cloudbees.jenkins.GitHubRepositoryName FINE logs stop just after the "object is" log entry, and i never see the evaluation or firing of the build for this case.

    I did see one build fire, but i don't exactly understand what or how it fired, i assumed it was the webhook, but maybe it built once for some other reason.

    "github hook log" contains ```

    Last GitHub Push

    Started on Jun 17, 2025, 9:49:07 PM Started by event from 140.82.115.9 ⇒

    https://app_jenkinsserver/github-webhook/

    on Tue Jun 17 21:49:07 UTC 2025 No existing build. Scheduling a new one. Done. Took 0 ms No changes ```

    i think there is another bug that should be reported, the hostname app_jenkinsserver seemed to be the docker container name, not the jenkins configuration url and whatever is formatting this string in this log appears to fail to use the configured base url.

it's possible i still don't understand the code well enough.
in my case, i have "My Freestyle Projects/my-project" with triggers {com.cloudbees.jenkins.GitHubPushTrigger$DescriptorImpl@​2bd4b183=com.cloudbees.jenkins.GitHubPushTrigger@​376a03ca[]}

repeat-delivery of the webhook i thought triggerd it doesn't re-trigger it.

my com.cloudbees.jenkins.GitHubRepositoryName FINE logs stop just after the "object is" log entry, and i never see the evaluation or firing of the build for this case.

I did see one build fire, but i don't exactly understand what or how it fired, i assumed it was the webhook, but maybe it built once for some other reason.

"github hook log" contains
```

Last GitHub Push

Started on Jun 17, 2025, 9:49:07 PM Started by event from 140.82.115.9 ⇒

https://app_jenkinsserver/github-webhook/

on Tue Jun 17 21:49:07 UTC 2025 No existing build. Scheduling a new one. Done. Took 0 ms No changes
```

i think there is another bug that should be reported, the hostname app_jenkinsserver seemed to be the docker container name, not the jenkins configuration url and whatever is formatting this string in this log appears to fail to use the configured base url.

jenkins-infra-bot avatar Jun 17 '25 22:06 jenkins-infra-bot