Hi, I'm using Jenkins 2.14, and am implementing a build with a 
Jenkinsfile.  As part of that build I'm looking to update Jira with some 
additional comments as to the output of the build.

The piece that is behaving strangely is this:

def previousJiraBuildAction = baseBuild.getAction(JiraBuildAction.class)
if (previousJiraBuildAction != null) {
    echo "issues to log: " + previousJiraBuildAction.issues.length
    for (int i=0; i < previousJiraBuildAction.issues.length; i++ ) { 
        //create a Jira Comment with the version number for the Issues 
found previously
        try {
            echo "adding comment to " + previousJiraBuildAction.issues[i].id
            jiraComment([issueKey : previousJiraBuildAction.issues[i].id, 
body : "New build created for ${component} with version ${version}"])
        } catch (Exception e) {
            //log error and carry on
            //this only seems to work if its not in a NonCPS method, 
otherwise the jiraComment call exits the loop, without an error
            echo "error " + e
        }
    }
    echo "after loop"
}

Prior to this method running a JiraIssueUpdater step has run, which can add 
several issues to the JiraBuildAction.

If I annotate the method this is running in with @NonCPS the loop gets to 
the first jiraComment, and then exits with no error message.  With the code 
like this I get a java.io.NotSerializableException, but it does seem to 
loop through all the issues and update them.

Are there any suggestions/thoughts as to why it might be silently exiting 
the loop?

Thanks in advance,

Matt

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/0d9fde56-abe3-4ade-a2e7-72e3cd38f418%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to