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

Expect library sources in custom subdirectory

XMLWordPrintable

      Hi.

      The current design of the shared library plugin doesn't play well with monolithic repositories. It forces a specific directory structure on the top level of the repository used for the library, which makes it very hard when a team want to keep all their sources (including the ones used by Jenkins) versioned in a single repository (following the monorepo paradigm).

      Our workflow might be a little strange, because we are a single team that uses a single Jenkins instance/cluster, but I am sure there are others who have the same setup.

      Basically, what we wanted to have is a single multi-branch Pipeline and a single global library, the multi-branch Pipeline delegates work to (because global libraries can use @Grab for example). In such a "simple" scenario, it makes sense to use a single repository for both the Jenkinsfile and the shared library.

      The way we have it set up is that the multi-branch Pipeline executes a simple Jenkinsfile that only determines what branch (or ref) it is running, then uses the `library` step to load the shared library with the same branch (or ref) and calls it, delegating all work to the shared library.

      This system, at least for us, is great, because when we work on, review and test out pull requests, every change can be done as part of a single pull request to a single repository.

      Anyway, I've actually gone ahead and implemented the possibility of specifying a custom directory from which to check out the library's sources. We've been using it for some time and I'd like to see if it could be merged upstream, so we could drop our fork of this great plugin.

      Here's the PR: https://github.com/jenkinsci/workflow-cps-global-lib-plugin/pull/40

            Unassigned Unassigned
            petr_motejlek Petr Motejlek
            Votes:
            5 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved: