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

jiraAddComment terminates the step prematurely

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Not A Defect
    • Component/s: jira-steps-plugin
    • Labels:
      None
    • Environment:
      jenkins 2.150.3
      Jira Pipeline Steps 1.4.4
    • Similar Issues:

      Description

      At the end of my pipeline, I am iterating the changeSets and the commits therein looking for strings that match Jira tickets, in order to update all Jira's with code present in a build.  In theory, this could result in multiple Jiras needing to be updated, so this is done in a loop, potentially making multiple calls to jiraAddComment(..).   However, the entire step stops (seems to return success) once the first jiraAddComment is completed.

      See attached source and output.  Following call to jiraAddComment(..), the subsequent echo should fire indicating that execution flow has continued.  The first jiraAddComment appears in the log (and the comment appears in Jira).  However, no subsequent echos in the log.  No subsequent call to jiraAddComment in the log, and no subsequent comments in Jira. 

      It is as-if execution stops at the first call to jiraAddComment

        Attachments

        1. output.txt
          1 kB
        2. output-final.txt
          4 kB
        3. output-stubCall.txt
          4 kB
        4. output-truncatedCall.txt
          2 kB
        5. source.txt
          4 kB

          Activity

          Hide
          nrayapati Naresh Rayapati added a comment -

          yeah, as I mentioned in the above comments, pipeline steps has be outside the @NonCPS function. 

          Show
          nrayapati Naresh Rayapati added a comment - yeah, as I mentioned in the above comments, pipeline steps has be outside the @NonCPS function. 
          Hide
          jbennett20912 Jeffrey Bennett added a comment -

          I'm inferring that if I use the @NonCPS method to build an array of Jiras to update (ID + Comment), pass the array back to the stage, iterate and call jiraAddComment for each element in the array (from the stage), it would work.  I think?

          My groovy skills are weak.  Built an array in the method, but cannot figure out how to get it back to the stage

           

           

           

          Show
          jbennett20912 Jeffrey Bennett added a comment - I'm inferring that if I use the @NonCPS method to build an array of Jiras to update (ID + Comment), pass the array back to the stage, iterate and call jiraAddComment for each element in the array (from the stage), it would work.  I think? My groovy skills are weak.  Built an array in the method, but cannot figure out how to get it back to the stage      
          Hide
          jbennett20912 Jeffrey Bennett added a comment -

          OK resolved it - many thanks.   Indeed, you have to build an array of Jiras to update in a method, then do the updating back in the stage (inside a script marker).

          I added my final code to output-final.txt in the hopes maybe it will benefit the next person.

          Naresh Rayapati  Thank you for the help!

          Issue can be closed

          Show
          jbennett20912 Jeffrey Bennett added a comment - OK resolved it - many thanks.   Indeed, you have to build an array of Jiras to update in a method, then do the updating back in the stage (inside a script marker). I added my final code to output-final.txt in the hopes maybe it will benefit the next person. Naresh Rayapati   Thank you for the help! Issue can be closed
          Hide
          jbennett20912 Jeffrey Bennett added a comment -

          work-around found.  Invocation of step from method is illegal.

          Show
          jbennett20912 Jeffrey Bennett added a comment - work-around found.  Invocation of step from method is illegal.
          Hide
          nrayapati Naresh Rayapati added a comment -

          No problem! Thank you for using this plugin. 

          Show
          nrayapati Naresh Rayapati added a comment - No problem! Thank you for using this plugin. 

            People

            • Assignee:
              nrayapati Naresh Rayapati
              Reporter:
              jbennett20912 Jeffrey Bennett
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: