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

            Hide
            abayer Andrew Bayer added a comment -

            Huh. That's weird. I almost certainly did something wrong. Looking into it. =)

            Show
            abayer Andrew Bayer added a comment - Huh. That's weird. I almost certainly did something wrong. Looking into it. =)
            Hide
            abayer Andrew Bayer added a comment -

            ...yup. I did. Reproduced it, working on it. Sorry!

            Show
            abayer Andrew Bayer added a comment - ...yup. I did. Reproduced it, working on it. Sorry!
            Show
            abayer Andrew Bayer added a comment - PR up at https://github.com/cloudbees/groovy-cps/pull/82
            Hide
            knitschi Uli Hierl added a comment -

            Wow, that was quick. Thank you for your effort!

            Show
            knitschi Uli Hierl added a comment - Wow, that was quick. Thank you for your effort!
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            pom.xml
            src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition2Test.java
            http://jenkins-ci.org/commit/workflow-cps-plugin/9a82584c267f84a4dce925a69d45ad6018196a0a
            Log:
            [JENKINS-45575, JENKINS-49679] Test multiple assignment CPS fixes

            Specifically https://github.com/cloudbees/groovy-cps/pull/81 and https://github.com/cloudbees/groovy-cps/pull/82

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pom.xml src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition2Test.java http://jenkins-ci.org/commit/workflow-cps-plugin/9a82584c267f84a4dce925a69d45ad6018196a0a Log: [JENKINS-45575, JENKINS-49679] Test multiple assignment CPS fixes Specifically https://github.com/cloudbees/groovy-cps/pull/81 and https://github.com/cloudbees/groovy-cps/pull/82
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            Jenkinsfile
            pom.xml
            src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition2Test.java
            http://jenkins-ci.org/commit/workflow-cps-plugin/78b137d8743ea3cf80ae302ec89f8aeabf3eb944
            Log:
            Merge pull request #206 from abayer/jenkins-45575-jenkins-49679

            [JENKINS-45575, JENKINS-49679] Test multiple assignment CPS fixes

            Compare: https://github.com/jenkinsci/workflow-cps-plugin/compare/57bda81325d5...78b137d8743e

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: Jenkinsfile pom.xml src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition2Test.java http://jenkins-ci.org/commit/workflow-cps-plugin/78b137d8743ea3cf80ae302ec89f8aeabf3eb944 Log: Merge pull request #206 from abayer/jenkins-45575-jenkins-49679 [JENKINS-45575, JENKINS-49679] Test multiple assignment CPS fixes Compare: https://github.com/jenkinsci/workflow-cps-plugin/compare/57bda81325d5...78b137d8743e
            Hide
            abayer Andrew Bayer added a comment -

            Will be in next release of workflow-cps - 2.46.

            Show
            abayer Andrew Bayer added a comment - Will be in next release of workflow-cps - 2.46.

              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: