spinnaker: Pipeline templates do not resolve variables is if the line contains other pipeline expression MPT v2

Issue Summary:

Pipeline templates do not resolve variables is if the line contains other pipeline expression MPT v2

Environment:

MPT v2 1.14.5

Description:

 "defaultArtifact": {
        "kind": "default.docker",
        "name": "gcr.io/${ templateVariables.gcr }/${ templateVariables.imageName }-migration",
        "reference": "gcr.io/${ templateVariables.gcr }/${ templateVariables.imageName }-migration:${ trigger['resolvedExpectedArtifacts'][0]['boundArtifact']['version'] }",
        "type": "docker/image",
},

The parameter “name” is successfully resolved, but the “reference” is not.

Additional Details:

Orca logs : 2019-06-13 15:50:05.968 INFO 1 — [0.0-8083-exec-1] c.n.s.o.p.e.ExpressionTransform : [] Failed to evaluate ${trigger[‘resolvedExpectedArtifacts’][0][‘boundArtifact’][‘version’]}, returning raw value EL1012E: Cannot index into a null value


About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17

Most upvoted comments

We have seen this issue. Our work around was to escape the ${ with ${'${'} for the parameter. So it would end up looking like ${ templateVariables.valOne }/${'${'}parameters['valTwo']}

impressive, but I also feel like crying

We are experiencing the same issue with version 1.19.3, will this be address anytime soon ? Seems to be an old issue with no acknowledge from core team.

I ran into this issue recently and was able to find a way to work around it for my use case. It’s hacky, but I ended up adding an Evaluate Variables stage before I needed the value of the template variable.

In that stage, I created a new variable with the value as the template variable reference. When the stage renders in a pipeline, the value of that new variable is the value of the template variable. You can then use that new variable inline with pipeline expressions.

Not ideal, but it did the trick.

Also hitting this - it’s not even limited to other pipeline expressions. Anything with ${} syntax will do it. For example, consider a Run Job stage that does some expression with a variable and uses bash substring syntax to extract data.

We have seen this issue. Our work around was to escape the ${ with ${'${'} for the parameter. So it would end up looking like ${ templateVariables.valOne }/${'${'}parameters['valTwo']}