jenkinsjenkins-github-plugin

Jenkins Organization Folder scan doesn't detect repositories


The Jenkins Scan Organization Folder Log looks like this:

Started by user Obay Abdelagdir
[Thu Dec 31 16:45:21 UTC 2020] Starting organization scan...
[Thu Dec 31 16:45:21 UTC 2020] Updating actions...
Looking up details of my-org-name...
Organization URL: https://github.com/my-org-name
[Thu Dec 31 16:45:22 UTC 2020] Consulting GitHub Organization
Connecting to https://api.github.com using 94421/****** (Github App, necessary for publishing checks)
Looking up repositories of organization my-org-name
0 repositories were processed
[Thu Dec 31 16:45:23 UTC 2020] Finished organization scan. Scan took 1.3 sec
Finished: SUCCESS

Jenkins "Github Organization Folder" details: I tried to follow the instructions here, but without installing the "Github App" to the organization (installed on the user), and I ignored the Configuration as Code Plugin section.

Github App details: The "Github App" was created with a normal github user, and it is installed on that user who has owner permission on the organization. Because I couldn't install it on the organization directly. Edit: I was able to transfer the ownership of the app to the organization and installed it, but the same issue is still there.

My Problem: It says in the log above 0 repositories were processed. But I have one branch in the organization, that have a file named .jenkinsfile (and yes, I added it to the "Project Recognizers") with the following contents:

pipeline {
  stages {
    stage('Static Code Analysis') {
      parallel {
        stage('Pylint') {
          agent {
            label "pylint"
          }
          steps {
            sh "pylint --exit-zero --load-plugins=pylint_odoo 0-e odoolint --rcfile=./.pylintrc * > pylint.log"
          }
        }
      }
    }
  }
}

Another problem is that the github checks is not working, it gives the following on the build log:

[GitHub Checks] Failed Publishing GitHub checks: org.kohsuke.github.GHFileNotFoundException: https://api.github.com/repos/my-org-name/my-repo {"message":"Not Found","documentation_url":"https://docs.github.com/rest/reference/repos#get-a-repository"}
[GitHub Checks] Failed Publishing GitHub checks: org.kohsuke.github.GHFileNotFoundException: https://api.github.com/repos/my-org-name/my-repo {"message":"Not Found","documentation_url":"https://docs.github.com/rest/reference/repos#get-a-repository"}
Finished: SUCCESS

Solution

  • To answer my own question.

    The github app MUST be installed on the organization. The best (and maybe only) way to do it is as follows:

    1. Login with your normal user account
    2. Open the organization url, https://github.com/YOUR-ORG-NAME
    3. Open the Settings tab, the click Developer settings
    4. Under Developer settings there should be two options OAuth Apps and Github Apps, click on Github Apps
    5. Then follow the instructions from the plugin docs noramlly.
    6. finally make sure to install the app in the organization.