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

Create a method to load Jenkins shared library

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Major Major
    • job-dsl-plugin
    • None

      It would be a great benefit to be able to load a pre defined Jenkins shared library in Jenkins. 
      for instance constant classes that are defined in the shared library could be useful to be used within the Job definition 

      1- within the job dsl definition

      e.g. a job dsl file:

      @Library('jenkins-shared-library') _

      import com.name.Test.Conf

      pipelineJob('Test')

      { description(Conf.DESCRIPTION) . . }

       

       

      2- within the importable classes accessible to the job script 

      for instance in the repo there is a

      job.groovy

      Foo/Bar.groovy 

       

      in Bar.groovy it would be possible to import classes from Jenkins shared library (assuming @Library used in the job would already load the library, making its classes importable by the job accessible classes)

      content of Bar :
      package Foo

      import com.name.Test.Conf

      class Bar

      {  Public final A = Conf.VALUE Public final B = 'test' }

       

      contents of job.groovy:

      @Library('jenkins-shared-library') _

      import com.name.Test.Conf

      import Foo.Bar

      def local = new Bar()

       

      def C = local.B

      pipelineJob('Test')

      { description(Conf.DESCRIPTION)   C used in the job anywhere    . . }

       

       

       

            jamietanna Jamie Tanna
            vmicrodev Vmicro
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: