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

Shared-Library Import without def causes MultipleCompilationErrorsException

XMLWordPrintable

      I've just spend several hours, trying to find out why my multi-branch-pipeline project was failing until I found this problem using trial and error.

      I have a multi-branch-pipeline with a shared library. That shared library is already in use with other projects and works fine. After copy & pasting some code to a new Jenkinsfile I was wondering why it did not work.

      Faulty Jenkinsfile:

      @Library('shared-lib@master')

      testing.sayHello('World')

       

      This causes the build to fail with:
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      WorkflowScript: 3: unexpected token: testing @ line 3, column 1.
      testing.sayHello('World')
      ^

       

      When I edit my Jenkinsfile to:

      @Library('shared-lib@master')

      def anything = 'nothing'

      testing.sayHello('World')

       

       

      it executes without any error.

            Unassigned Unassigned
            dime Dominic S.
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: