spinnaker: `templateVariables` ignored when using SPeL Expressions

Issue Summary:

When creating a pipeline-template that is using templateVariables and SPeL Expressions, templateVariables are ignored when attempting to create a Spinnaker pipeline from it.

Cloud Provider(s):

Kubernetes

Environment:

1.19.2/1.19.3

Feature Area:

Pipeline Expressions

Description:

When defining a pipeline-template, under the pipeline json object where you define the stages for the template, it will not interpolate ${templateVariables.myTemplateVariable} if the "spelEvaluator": "v4" is included in the pipeline definition.

So using this for example:

{
    "schema": "v2",
    "variables": [
      {
        "type": "string",
        "defaultValue": "my-app",
        "description": "Stash Repo used as Application Name in Spinnaker",
        "name": "stashRepo"
      }
    ],
    "id": "my-template",
    "metadata": {
      "name": "my-template",
      "description": "test-template",
      "scopes": ["global"]
    },
    "pipeline": {
      "keepWaitingPipelines": false,
      "limitConcurrent": true,
      "spelEvaluator": "v4",
      "stages": [{
          "failOnFailedExpressions": true,
          "name": "Evaluate Webhook Event",
          "refId": "1",
          "requisiteStageRefIds": [],
          "type": "evaluateVariables",
          "variables": [{
            "key": "eventType",
            "value": "${ trigger.payload.eventKey }"
          }]
        }
      ],
      "triggers": [{
        "enabled": true,
        "payloadConstraints": {},
        "source": "${templateVariables.stashRepo}",
        "type": "webhook"
      }]
  
    }
  }

When "spelEvaluator" :"v4" is present, ${templateVariables.stashRepo} is ignored and shows up in the rendered pipeline as ${templateVariables.stashRepo}, not what was passed in as the variable value when creating the pipeline. However, ${ trigger.payload.eventKey } is rendered correctly.

If I were to get rid of "spelEvaluator" :"v4", then ${templateVariables.stashRepo} resolves correctly. As far as I know, templateVariables should still be able to be used even though the SPeL is enabled for the pipeline-template.

Steps to Reproduce:

  1. Create a pipeline-template with templateVariables without the spelEvaluator bit in your pipeline-template json
  2. Create a pipeline with that pipeline-template
  3. Double check that the templateVariable was resolved correctly with the variable passed in upon pipeline creation
  4. Modify the pipeline-template and add the "spelEvaluator" :"v4" under the pipeline section in your pipeline-template json.
  5. Push modified pipeline-template and check the pipeline that was created to see that the templateVariable is no longer able to be resolved with the variable passed in upon pipeline creation.

Additional Details:

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 22 (1 by maintainers)

Most upvoted comments

Confirming that having "spelEvaluator": "v4" is still an issue on Spinnaker v1.21.2 with regards to using templateVariables.

Using "spelEvaluator": "v3" does work.