I see in the "Pipeline Steps" there is "echo". I don't see "println". When I execute a Jenkinsfile with a "println" statement, I see "[Pipeline] echo" printed before the output line, as if "println" is just a synonym for "echo".
If I change the statement to use "echo" instead, it appears to do exactly the same.
The other confusion has to do with the semantics of "Pipeline Steps". I've been informed in several ways that you can't execute "Pipeline Steps" in a @NonCPS-annotated method. I've also been told that all the choices in the "Snippet Generator" dropdown are pipeline steps. However, I just tested the following pipeline:
node {
stage ("testing") {
def list = ["abc", "def"]
listIterator(list)
listIterator2(list)
println "done."
}
}
@NonCPS
def listIterator(List<String> list) {
list.each { item -> println "item[${item}]" }
}
@NonCPS
def listIterator2(List<String> list) {
list.each { item -> echo "item[${item}]" }
}
Here's the output from running that pipeline:
[Pipeline] {
[Pipeline] stage
[Pipeline] { (testing)
[Pipeline] echo
item[abc]
[Pipeline] echo
item[def]
[Pipeline] echo
item[abc]
[Pipeline] echo
item[def]
[Pipeline] echo
done.
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
In my experience, if you execute a "pipeline step" within a @NonCPS-annotated method, the behavior I see is that it appears to just exit the pipeline at the point where it would have executed that statement. As you can see, this pipeline managed to get to the last instruction of the pipeline (printing "done"), but the "listIterator2" method has @NonCPS, and it calls "echo", which is a pipeline step.