Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

By default, the parameters and variables of a an automation pipeline YAML script are fixed and static values. In some use cases this is not sufficient enough since such these values must be calculated, validated, re-wired or prepared before they can be passed to a command. This is what a the Pipeline Expression Language (PEL) can be used for.

The Pipeline Expression Language (PEL) or just PE (Pipeline Expression) is a powerful and easy to learn expression language based on Spring EL and adds additional features to this widely used "defacto-standard" expression language. It can be used inside a an automation pipeline to access a specific portion of data and dynamically calculate, convert or set values.

The Pipeline Expression Language is optional in a pipeline YAML. You do not need it for basic tasks working with PIPEFORCE. But it gives you additional more flexibility and power to automate and integrate nearly any process without the need to learn a complex programming language. So it is wise to learn at least the basics of it.

...

Typically a PE (Pipeline Expression) starts with ${ and ends with }. Here is a simple example of a PE, placed inside the value of a command parameter:

Code Block
languageyaml
pipeline:
  - body.set:
      value: ${1 + 1}

...

Info

The PE prefix #{ is only meant as an alternative in case ${ cannot be used in some situations. Using ${ should be preferred whenever possible.

A PE can be placed in the value part of pipeline headers and variables, in parameter values of most commands and in the body of a pipeline.

...

Output:

Code Block
Result: 2

Accessing

...

Pipeline Objects (headers, vars, body, request, …)

Using a Pipeline Expression, you can access the values (= attributes) inside pipeline scopes like headers, vars, and body in order to read and write them.

These scopes are provided automatically as implicit objects and therefore they're always available inside any pipeline expression even if no section like headers:, vars: or body: or was declared or any other allocation was done.

Also see: Implicite Pipeline Objects Reference .

vars (variables)

This object gives you access to all variables of the current pipeline.

Also see https://logabit.atlassian.net/wiki/spaces/PA/pages/2552856577#vars2552856577/Pipeline+Objects#vars .

Let's assume, you have defined a variable counter and you would like to access this counter in your expression, then you could write an expression like this:

...

This object gives you access to all pipeline headers of the current pipeline.

Also see https://logabit.atlassian.net/wiki/spaces/PA/pages/2552856577/2552856577#headersPipeline+Objects#headers .

Info

Do not mix up Pipeline headers with HTTP headers. The latter can be accessed using the ${request.headers} object instead.

...

This object gives you access to the current body of the current pipeline.

Also see https://logabit.atlassian.net/wiki/spaces/PA/pages/2552856577#body2552856577/Pipeline+Objects#body .

Here is an example which defines an initial body value and replaces this with another text in the pipeline:

...

For more information about all available implicit objects and their attributes, see:
Implicite Pipeline Objects Reference

Navigating nested data structures

A Pipeline Expression can also point be used to navigate and extract nested attributes inside from an object or array, like this JSON for example:

Code Block
languagejson
{
  "person": {
    "name": "Bart Simpson",
    "age": 12,
    "hobbies": [
      "skateboard",
      "tv",
      "pranks"
    ]
  }
}

You can navigate and read any structured object available inside the scopes using the dot operator. For example:

...

Info

Note: The dot operator is easier to use but throws an exception in case the name attribute doesn't exist. The associative array navigator don't.

And to access entries in a list/array, you can use the index operator []:

...