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

Support for Namespacing global variables

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Won't Do
    • Icon: Minor Minor
    • None
    • workflow-cps-global-lib:2.8
      core:2.60.3

      When managing numerous global functions in a Pipeline Shared library repository, it quickly become unmanageable. It could also be prone to conflict with current / future pipeline steps - if for example I have a global variable foo and a couple of weeks later pipeline basic steps introduce a new step foo.

      It would be great to have the ability to organize global functions in sub-directories and/or use some kind of namespacing for Global Variables.

      For example:

      vars/artifactory/runMaven.groovy 
      vars/artifactory/runGradle.groovy 
      vars/docker/build.groovy
      vars/docker/deploy.groovy
      

      Which can be used in a Pipeline as:

      node {
          artifactory.runMaven()
          artifactory.runGradle()
          docker.build()
          docker.deploy()
      }
      

      Workaround

      A potential workaround to this is to create static methods in Global Variable, each variable giving access to the methods:

      // vars/Artifactory.groovy
      
      def runMaven() {
          echo "Running some Maven stuff "
      }
      
      def runGradle() {
          echo "Running some Gradle stuff"
      }
      

      Which can be used in a pipeline like the following:

      node {
          Artifactory.runMaven()
          Artifactory.runGradle()
      }
      

      But supporting directories for Global Variables is more scalable and seems a good candidate for improvement.

            Unassigned Unassigned
            allan_burdajewicz Allan BURDAJEWICZ
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: