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.
--
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/ec5d5e6b-987b-43a7-a60a-a78c58c74340%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.