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

Return value unpacking in pipelinescript causes function to execute twice.

    Details

    • Similar Issues:

      Description

      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.

        Attachments

          Issue Links

            Activity

            knitschi Uli Hierl created issue -
            abayer Andrew Bayer made changes -
            Field Original Value New Value
            Assignee Andrew Bayer [ abayer ]
            abayer Andrew Bayer made changes -
            Component/s workflow-cps-plugin [ 21713 ]
            Component/s pipeline [ 21692 ]
            abayer Andrew Bayer made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            abayer Andrew Bayer made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            abayer Andrew Bayer made changes -
            Remote Link This issue links to "PR #82 (Web Link)" [ 20134 ]
            abayer Andrew Bayer made changes -
            Status In Review [ 10005 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: