And I think you can remove the 'currently' from my sentence. What's 'currently' definitely missing is that it should immediately fail with a clear error.
Indeed, what Continuation passing style (CPS) gives you is the durability of your pipeline. Said differently, it means each step (in the general meaning) is checkpointed, in case of a crash for example to be able to restart from where it left. So calling non CPS code from CPS one is going to be something like "OK, call that thing if you will, I'll stay there waiting for you. If you never back, well we'll restart from where I am now" (which is BTW already typically the case each time you call a shell step and so on: if your shell script takes one hour of complex things and fail, it will simply get back to the beginning of it. Not where that script left). If you think about it, the other way, calling CPS code from non CPS is probably weirder: you are in a non serializable place (non CPS code), and you call something designed to take care of what it did and where it left. Note this is my understanding of all that. Jesse will probably correct me soon if I'm wrong :). Le 8 août 2016 1:41 PM, Baptiste Mathus <[email protected]> a écrit : > Probably https://issues.jenkins-ci.org/browse/JENKINS-31314 > > It's currently unsupported to call DSL steps from NonCPS code. > > Cheers > > Le 8 août 2016 2:35 AM, "Matthew Harrison" <[email protected]> > a écrit : > >> 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/ms >> gid/jenkinsci-users/0d9fde56-abe3-4ade-a2e7-72e3cd38f418% >> 40googlegroups.com >> <https://groups.google.com/d/msgid/jenkinsci-users/0d9fde56-abe3-4ade-a2e7-72e3cd38f418%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- 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/CANWgJS7oTe-5xRXNG0ETeFQZZ5Fs%3DVPbgy%3DtP9TLGsBNBc37ow%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
