Spinnaker Pipeline SpEL Expressions: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 18: Line 18:
</font>
</font>
==The Judgment Value set by a Manual Judgment Stage==
==The Judgment Value set by a Manual Judgment Stage==
{{External|https://spinnaker.io/docs/reference/pipeline/expressions/#judgmentstring}}
The value selected by a specific Manual Judgment option can be accessed by subsequent stages with the following expression:
<syntaxhighlight lang='groovy'>
<syntaxhighlight lang='groovy'>
${#judgment("<stage-name>")}
${execution.stages.?[name == '<stage-name>' ][0].context.judgmentInput}
</syntaxhighlight>
</syntaxhighlight>
returns the selected judgment value from the specified Manual Judgment stage. <code><stage-name></code> should be replaced with the actual name of the Manual Judgment stage
The expression can be used in the "Conditional on Expression" clause of subsequent stages as follows:
Example:
<syntaxhighlight lang='groovy'>
${execution.stages.?[name == '<stage-name>' ][0].context.judgmentInput == '<option-value>'}
</syntaxhighlight>
where <code>stage-name</code> should be replaced with the actual name of the Manual Judgment stage and <code><option-value></code> with the actual option value using the same capitalization.
 
An alternative to get the selected option value is to use the <code>${#judgment()</code> function. <font color=darkkhaki>Did not manage to make it work, more experimentation is necessary.</font> For more details see: {{External|https://spinnaker.io/docs/reference/pipeline/expressions/#judgmentstring}}
<syntaxhighlight lang='groovy'>
<syntaxhighlight lang='groovy'>
${#judgment("<stage-name>")}
${#judgment("<stage-name>")}
</syntaxhighlight>
</syntaxhighlight>
execution.stages[n].context.judgmentInput=="rollback"


=Displaying Pipeline State at Runtime=
=Displaying Pipeline State at Runtime=

Revision as of 03:23, 24 March 2022

External

Internal

Overview

The Spinnaker pipeline expression language is based on Spring Expression Language (SpEL).

Accessing Pipeline Element State

A Tag set by a Trigger

The tag set by a trigger can be accessed with the following expression:

- image: "something/something-else:${trigger['tag']}"

The Judgment Value set by a Manual Judgment Stage

The value selected by a specific Manual Judgment option can be accessed by subsequent stages with the following expression:

${execution.stages.?[name == '<stage-name>' ][0].context.judgmentInput}

The expression can be used in the "Conditional on Expression" clause of subsequent stages as follows:

${execution.stages.?[name == '<stage-name>' ][0].context.judgmentInput == '<option-value>'}

where stage-name should be replaced with the actual name of the Manual Judgment stage and <option-value> with the actual option value using the same capitalization.

An alternative to get the selected option value is to use the ${#judgment() function. Did not manage to make it work, more experimentation is necessary. For more details see:

https://spinnaker.io/docs/reference/pipeline/expressions/#judgmentstring
${#judgment("<stage-name>")}

Displaying Pipeline State at Runtime

Conditional Expressions

https://spinnaker.io/docs/reference/pipeline/expressions/#comparisons
 ${ execution.stages.?[ name == 'Rollback Decision' ][0].judgementInput == 'Rollback' }