Document how to use shared library's global classes in Declarative

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      Given the following file in a shared library's vars folder

      class acme implements Serializable {
          
          def script
          
          acme(script) {this.script = script}
      }
      

      And the following snippet of Declarative code

      stages {
              stage("Checking component sources and building snapshot") {
                  steps {
                      script {
                          acme = new acme(this)
                      }
                   }
                 }
      }
      

      The end result is an error like

      Unable to resolve class acme
      

      To make this work I need to move the acme initialization out of the pipeline block like this

      def acme = new acme(this)
      
      pipeline {
       .......
      

      Although that is good to me as now the acme instance is available to all stages the current documentation does not mention anything related to this and I believe is worthwhile to add this case to the documentation.

            Assignee:
            Unassigned
            Reporter:
            Raul Arabaolaza
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Archived: