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

Stable API for reading REST URL from BitbucketSCMSource

      I'd like the Bitbucket Server Integration plugin to provide a stable Java API from which other plugins can read parameters for Bitbucket Server REST APIs. The other plugin has an SCMSource and wants to know:

      • Whether this SCMSource came from the Bitbucket Server Integration plugin.
      • The root URI for Bitbucket Server REST APIs.
      • The credential ID for Bitbucket Server REST APIs, or the credential itself. Not the admin token from the global configuration.
      • Project key
      • Repository slug

      All of this information is already available from classes and methods that the Bitbucket Server Integration plugin declares as public. However, all the classes are within the package com.atlassian.bitbucket.jenkins.internal (javadoc), which suggests that Atlassian might not want to support them as a stable API. The Bitbucket Server Integration plugin does not have any @Restricted annotations at all.

      Context: https://github.com/jenkinsci/checks-api-plugin/issues/65#issuecomment-765024815 and https://jira.atlassian.com/browse/BSERV-11477?focusedCommentId=2647677&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-2647677

          [JENKINS-64691] Stable API for reading REST URL from BitbucketSCMSource

          I imagine there are two ways to do this:

          • Define a stable interface that provides getters for this information. Place the interface in a non-"internal" package, e.g. com.atlassian.bitbucket.jenkins.api.BitbucketRestLocator. Implement the interface in BitbucketSCMSource.
          • Alternatively, document which parts of the API are stable even though they are in "internal" packages. Preferably, add annotations so that other plugins can be verified.

          Kalle Niemitalo added a comment - I imagine there are two ways to do this: Define a stable interface that provides getters for this information. Place the interface in a non-"internal" package, e.g. com.atlassian.bitbucket.jenkins.api.BitbucketRestLocator. Implement the interface in BitbucketSCMSource. Alternatively, document which parts of the API are stable even though they are in "internal" packages. Preferably, add annotations so that other plugins can be verified.

          If the following could be documented as stable, then that would be fine.

          • com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCMSource extends jenkins.scm.api.SCMSource, so that a dependent plugin can check whether the SCMSource is a BitbucketSCMSource
          • com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCMSource#getBitbucketSCMRepository
          • com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCMRepository#getCredentialsId
          • com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCMRepository#getServerId
          • com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCMRepository#getProjectKey
          • com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCMRepository#getRepositorySlug
          • com.atlassian.bitbucket.jenkins.internal.config.BitbucketPluginConfiguration extends jenkins.model.GlobalConfiguration, so that a dependent plugin can call Jenkins#getExtensionList(GlobalConfiguration.class) and recognize BitbucketPluginConfiguration from the results
          • com.atlassian.bitbucket.jenkins.internal.config.BitbucketPluginConfiguration#getServerById
          • com.atlassian.bitbucket.jenkins.internal.config.BitbucketServerConfiguration#getBaseUrl

          Kalle Niemitalo added a comment - If the following could be documented as stable, then that would be fine. com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCMSource extends jenkins.scm.api.SCMSource, so that a dependent plugin can check whether the SCMSource is a BitbucketSCMSource com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCMSource#getBitbucketSCMRepository com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCMRepository#getCredentialsId com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCMRepository#getServerId com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCMRepository#getProjectKey com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCMRepository#getRepositorySlug com.atlassian.bitbucket.jenkins.internal.config.BitbucketPluginConfiguration extends jenkins.model.GlobalConfiguration, so that a dependent plugin can call Jenkins#getExtensionList (GlobalConfiguration.class) and recognize BitbucketPluginConfiguration from the results com.atlassian.bitbucket.jenkins.internal.config.BitbucketPluginConfiguration#getServerById com.atlassian.bitbucket.jenkins.internal.config.BitbucketServerConfiguration#getBaseUrl

          Alternatively, if com.atlassian.bitbucket.jenkins.internal.scm.BitbucketJobLinkActionFactory#getBitbucketSCMRepository were public and stable, then com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCMSource would not be needed.

          Kalle Niemitalo added a comment - Alternatively, if com.atlassian.bitbucket.jenkins.internal.scm.BitbucketJobLinkActionFactory#getBitbucketSCMRepository were public and stable, then com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCMSource would not be needed.

          Kalle Niemitalo added a comment - - edited

          On the other hand, if the workspace includes more than one Git checkout (from Git submodules, or from pipeline steps such as bbs_checkout or checkout), then it might also be useful to have a stable API that takes a hudson.scm.SCM (i.e. com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCM) as input. BitbucketJobLinkActionFactory is not capable of that.

          Kalle Niemitalo added a comment - - edited On the other hand, if the workspace includes more than one Git checkout (from Git submodules, or from pipeline steps such as bbs_checkout or checkout ), then it might also be useful to have a stable API that takes a hudson.scm.SCM (i.e. com.atlassian.bitbucket.jenkins.internal.scm.BitbucketSCM) as input. BitbucketJobLinkActionFactory is not capable of that.

          See also https://github.com/jenkinsci/bitbucket-branch-source-plugin/issues/447 for the alternative Bitbucket Branch Source plugin.

          Kalle Niemitalo added a comment - See also https://github.com/jenkinsci/bitbucket-branch-source-plugin/issues/447 for the alternative Bitbucket Branch Source plugin.

            Unassigned Unassigned
            kon Kalle Niemitalo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: