Spinnaker Pipeline SpEL Expressions: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 35: Line 35:
<syntaxhighlight lang='groovy'>
<syntaxhighlight lang='groovy'>
${execution.stages.?[name == 'Deploy in Prod'][0].artifacts.reference}
${execution.stages.?[name == 'Deploy in Prod'][0].artifacts.reference}
</syntaxhighlight>
==Access an Output Produced by a Run Job (Manifest)==
The output name is "replicas":
<syntaxhighlight lang='groovy'>
${ execution.stages.?[ name == 'Script Job' ][0].outputs.replicas }
</syntaxhighlight>
</syntaxhighlight>



Revision as of 09:31, 30 April 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>")}

The Kind and Name of a Manifest Deployed by a Deployment Stage

${execution.stages.?[name == 'Deploy in Prod'][0].artifacts.reference}

Access an Output Produced by a Run Job (Manifest)

The output name is "replicas":

${ execution.stages.?[ name == 'Script Job' ][0].outputs.replicas }

Displaying Pipeline State at Runtime

TODO

Conditional Expressions

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

Variable

Also see:

Evaluate Variables stage