Pipeline Body
The body of a pipeline usually contains the data to be prepared during a pipeline execution. The body will be passed to any command in a pipeline flow one after another. And any command can then read and change the body. At the very end, the data in the body will finally be send to the caller.
The body stack (store body data to temp stack)
SINCE VERSION 9.0
In some cases the current data in the body needs to be temporarly saved for later use. So any next command can overwrite the existing body data. For this, you can store the current body value to a variable and later reset this value into the body. An easier and better approach is to use the body stack with the commands body.push
, body.peek
and body.pop
. This way you can simply "hide" the current body value using body.push
and unhide it using the command body.peek
or body.pop
:
body.push
= Adds the current data in the body to the stack.body.peek
= Moves the current data from the stack back to the body, without removing it from the stack.body.pop
= Moves the current data from the stack back to the body and removes it from the stack.
Example:
pipeline:
# Create data in the body
- body.set: "ORIGIN VALUE"
# Save the body data temporarly "away" for later use
- body.push
# Do something else with current body
- body.set: "NEW VALUE"
# "Reset" the body value from stack
- body.pop
When executing this pipeline, the final output will be:
"ORIGIN VALUE"
The origin value was reset to the body at the very end. So there is no need to extra create and manage variables for that.
You can also call body.push
several times. With every call the current data in the body will be stored to the stack. Just make sure that you do a body.pop in the same reverse order to reload the data back.
Note: The command body.push
puts the reference to the body data to the stack. It doesn't create a copy. So in case you are changing the same data somewhere else, it will also change in the stack!
In case you would like to handle multiple stacks, you can also define the stack name using the same name
parameter on body.push
, body.peek
and body.pop
accordingly.