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

Additions to Github APIs for Organizations and Repositories

    XMLWordPrintable

    Details

    • Epic Link:
    • Sprint:
      pannonian, iapetus
    • Similar Issues:

      Description

      I would like to request two additions to the Github APIs.

      When listing organizations via /jenkins/scm/github/organizations/?credentialId=github the response is currently:

      [{
          "_class": "io.jenkins.blueocean.blueocean_github_pipeline.GithubOrganization",
          "_links": {
              "repositories": {
                  "_class": "io.jenkins.blueocean.rest.hal.Link",
                  "href": "/organizations/jenkins/scm/github/organizations/jenkinsci/repositories/"
              },
              "self": {
                  "_class": "io.jenkins.blueocean.rest.hal.Link",
                  "href": "/organizations/jenkins/scm/github/organizations/jenkinsci/"
              }
          },
          "avatar": "https://avatars.githubusercontent.com/u/107424?v=3&s=50",
          "jenkinsOrganizationPipeline": false,
          "name": "jenkinsci"
      }, {
          "_class": "io.jenkins.blueocean.blueocean_github_pipeline.GithubUserOrganization",
          "_links": {
              "repositories": {
                  "_class": "io.jenkins.blueocean.rest.hal.Link",
                  "href": "/organizations/jenkins/scm/github/organizations/cliffmeyers/repositories/"
              },
              "self": {
                  "_class": "io.jenkins.blueocean.rest.hal.Link",
                  "href": "/organizations/jenkins/scm/github/organizations/cliffmeyers/"
              }
          },
          "avatar": "https://avatars.githubusercontent.com/u/143466?v=3&s=50",
          "jenkinsOrganizationPipeline": true,
          "name": "cliffmeyers"
      }, {
          "_class": "io.jenkins.blueocean.blueocean_github_pipeline.GithubOrganization",
          "_links": {
              "repositories": {
                  "_class": "io.jenkins.blueocean.rest.hal.Link",
                  "href": "/organizations/jenkins/scm/github/organizations/cloudbees/repositories/"
              },
              "self": {
                  "_class": "io.jenkins.blueocean.rest.hal.Link",
                  "href": "/organizations/jenkins/scm/github/organizations/cloudbees/"
              }
          },
          "avatar": "https://avatars.githubusercontent.com/u/235526?v=3&s=50",
          "jenkinsOrganizationPipeline": false,
          "name": "cloudbees"
      }]
      

      1. For organizations where jenkinsOrganizationPipeline is true, could we add an additional field that indicates whether "auto discover" is enabled? This is equivalent to a Github org folder that was created without specifying any repository names (i.e. empty "repoNames" array)

      2. For organizations where jenkinsOrganizationPipeline is true, could we also add a HAL link to the Jenkins org folder? This will make REST API update calls much easier.

      When listing repositories via /jenkins/scm/github/organizations/cliffmeyers/repositories/?credentialId=github&pageNumber=1&pageSize=100 the response is currently:

      {
          "_class": "io.jenkins.blueocean.blueocean_github_pipeline.GithubRespositoryContainer",
          "_links": {
              "self": {
                  "_class": "io.jenkins.blueocean.rest.hal.Link",
                  "href": "/organizations/jenkins/scm/github/organizations/cliffmeyers/repositories/"
              }
          },
          "repositories": {
              "_class": "io.jenkins.blueocean.blueocean_github_pipeline.GithubRepositories",
              "_links": {
                  "self": {
                      "_class": "io.jenkins.blueocean.rest.hal.Link",
                      "href": "/organizations/jenkins/scm/github/organizations/cliffmeyers/repositories/repositories/"
                  }
              },
              "items": [{
                  "_class": "io.jenkins.blueocean.blueocean_github_pipeline.GithubRepository",
                  "_links": {
                      "self": {
                          "_class": "io.jenkins.blueocean.rest.hal.Link",
                          "href": "/organizations/jenkins/scm/github/organizations/cliffmeyers/repositories/repositories/blog-examples/"
                      }
                  },
                  "defaultBranch": "master",
                  "description": "Sample code from stuff on my blog",
                  "name": "blog-examples",
                  "permissions": {
                      "admin": true,
                      "push": true,
                      "pull": true
                  },
                  "private": false,
                  "fullName": "cliffmeyers/blog-examples"
              }, {
                  "_class": "io.jenkins.blueocean.blueocean_github_pipeline.GithubRepository",
                  "_links": {
                      "self": {
                          "_class": "io.jenkins.blueocean.rest.hal.Link",
                          "href": "/organizations/jenkins/scm/github/organizations/cliffmeyers/repositories/repositories/blueocean-plugin/"
                      }
                  },
                  "defaultBranch": "master",
                  "description": "Blue Ocean UI app",
                  "name": "blueocean-plugin",
                  "permissions": {
                      "admin": true,
                      "push": true,
                      "pull": true
                  },
                  "private": false,
                  "fullName": "cliffmeyers/blueocean-plugin"
              }, {
                  "_class": "io.jenkins.blueocean.blueocean_github_pipeline.GithubRepository",
                  "_links": {
                      "self": {
                          "_class": "io.jenkins.blueocean.rest.hal.Link",
                          "href": "/organizations/jenkins/scm/github/organizations/cliffmeyers/repositories/repositories/frontend-maven-plugin/"
                      }
                  },
                  "defaultBranch": "master",
                  "description": "\"Maven-node-grunt-gulp-npm-node-plugin to end all maven-node-grunt-gulp-npm-plugins.\" A Maven plugin that downloads/installs Node and NPM locally, runs NPM install, Grunt, Gulp and/or Karma.",
                  "name": "frontend-maven-plugin",
                  "permissions": {
                      "admin": true,
                      "push": true,
                      "pull": true
                  },
                  "private": false,
                  "fullName": "cliffmeyers/frontend-maven-plugin"
              }, {
                  "_class": "io.jenkins.blueocean.blueocean_github_pipeline.GithubRepository",
                  "_links": {
                      "self": {
                          "_class": "io.jenkins.blueocean.rest.hal.Link",
                          "href": "/organizations/jenkins/scm/github/organizations/cliffmeyers/repositories/repositories/java-utils/"
                      }
                  },
                  "defaultBranch": "master",
                  "description": "Utilities for Java",
                  "name": "java-utils",
                  "permissions": {
                      "admin": true,
                      "push": true,
                      "pull": true
                  },
                  "private": false,
                  "fullName": "cliffmeyers/java-utils"
              }],
              "lastPage": 3,
              "nextPage": 2,
              "pageSize": 4
          }
      }
      

      3. Could we add a field to the repository object that indicates whether a pipeline has already been created for it? This is important in the "update" scenario to avoid the user trying to create a repo that was already created.

        Attachments

          Issue Links

            Activity

            Hide
            cliffmeyers Cliff Meyers added a comment -

            If we drop "requestedRepos" we can't determine whether the user originally picked "autodiscover" or "one repo" and this has a profound implication on what we can do with the re-entrant flow for Github Creation. Seems appropriate to pull James Dumay into this conversation as he had originally conceived of the feature.

            Show
            cliffmeyers Cliff Meyers added a comment - If we drop "requestedRepos" we can't determine whether the user originally picked "autodiscover" or "one repo" and this has a profound implication on what we can do with the re-entrant flow for Github Creation. Seems appropriate to pull James Dumay into this conversation as he had originally conceived of the feature.
            Hide
            vivek Vivek Pandey added a comment -

            Cliff Meyers Ok, so all you need is to determine auto-discover or not. How about backend API returns a boolean - I was trying to avoid that but this seems like most logical solution given challenges listing requested repos. Sounds good to you?

            Show
            vivek Vivek Pandey added a comment - Cliff Meyers Ok, so all you need is to determine auto-discover or not. How about backend API returns a boolean - I was trying to avoid that but this seems like most logical solution given challenges listing requested repos. Sounds good to you?
            Hide
            cliffmeyers Cliff Meyers added a comment -

            Per discussion, boolean flag is okay as long as the "pipelines" array is preserved. This is important when a user wants to transition from "auto-discover" to "single repo" so that we can call the "update" REST API and provide accurate list for "repoNames": [].concat(pipelines, newRepoName)

            Show
            cliffmeyers Cliff Meyers added a comment - Per discussion, boolean flag is okay as long as the "pipelines" array is preserved. This is important when a user wants to transition from "auto-discover" to "single repo" so that we can call the "update" REST API and provide accurate list for "repoNames": [].concat(pipelines, newRepoName)
            Hide
            jamesdumay James Dumay added a comment -

            Cliff Meyers Vivek Pandey not sure what I should be chiming in here for?

            Show
            jamesdumay James Dumay added a comment - Cliff Meyers Vivek Pandey not sure what I should be chiming in here for?
            Hide
            cliffmeyers Cliff Meyers added a comment -

            James Dumay Vivek and I chatted earlier and sorted this out; we're all good for now.

            Show
            cliffmeyers Cliff Meyers added a comment - James Dumay Vivek and I chatted earlier and sorted this out; we're all good for now.

              People

              • Assignee:
                vivek Vivek Pandey
                Reporter:
                cliffmeyers Cliff Meyers
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: