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

Return value unpacking in pipelinescript causes function to execute twice.

XMLWordPrintable

      Consider the following pipeline script.

      jenkinsfile
      def str1 = ''
      def str2 = ''
      (str1, str2) = addStage()
      
      def addStage()
      {
          stage('Stage 1')
          {
              node('master')
              {
                  sh 'echo run stage'
              }
          }
          
          return ['foo', 'bar']
      }
      

      When running the pipeline it will execute the shell command twice. This came unexpected to me and I think it is a bug. When the parameter unpacking is removed from the third line, the script behaves as expected.

            abayer Andrew Bayer
            knitschi Uli Hierl
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: