"Accessing steps" example in Extending with Shared Libraries fails

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

XMLWordPrintable

      In trying the examples from the "extending with Shared Libraries" documentation found here:

      https://jenkins.io/doc/book/pipeline/shared-libraries/

      other examples work without issues, but the first example under "Accessing steps" suggests using a method outside of an enclosing class:

      // src/org/foo/Zot.groovy
      package org.foo;

      def checkOutFrom(repo) {
        git url: "git@github.com:jenkinsci/${repo}"
      }

      called like this:

      def z = new org.foo.Zot()
      z.checkOutFrom(repo)

       

      When I try this, it fails to resolve the class:

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      WorkflowScript: 9: unable to resolve class org.foo.Zot
      @ line 9, column 17.
      def z = new org.foo.Zot()
      ^

      1 error

      at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
      at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:958)
      at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:605)
      at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:554)
      at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
      at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
      at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
      at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
      at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:129)
      at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:123)
      at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:517)
      at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:480)
      at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:268)
      at hudson.model.ResourceController.execute(ResourceController.java:97)
      at hudson.model.Executor.run(Executor.java:421)
      Finished: FAILURE

       

      The error isn't all that surprising, since this really isn't a class.  It looks like perhaps there's something missing from the example in the documentation.

            Assignee:
            Unassigned
            Reporter:
            Andrew Lawrence
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: