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

Global function with no parameters silently ignored when called without parenthesis

XMLWordPrintable

      Calling code (e.g. Jenkinsfile or script via load):

      testGlobalFunction
      

      Global function:

      /var/lib/jenkins/workflow-libs/vars/testGlobalFunction.groovy
      #!/usr/bin/env groovy
      import com.github.jenkinsci.WorkflowCpsGlobalLibPluginTest
      /**
       * @author rbellamy@terradatum.com
       */
      def call() {
        def flow = new WorkflowCpsGlobalLibPluginTest()
      
        flow.dockerLogin()
      }
      

      Workflow function:

      /var/lib/jenkins/workflow-libs/src/com/github/jenkinsci/WorkflowCpsGlobalLibPluginTest.groovy
      package com.github.jenkinsci
      def void dockerLogin() {
        echo 'testGlobalFunction'
      }
      
      return this
      

      Expected behavior:
      Echo 'testGlobalFunction' to output.

      Actual behavior:
      No output, job marked as success.

      Calling that works:

      testGlobalFunction()
      

            Unassigned Unassigned
            rbellamy G. Richard Bellamy
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: