How can I template an artifact reference in an upstream Spinnaker stage?

1/14/2019

Looking at the source of one of my Spinnaker pipelines, my Build stage has the following artifact listed in it's context:

"context": {
    "account": "default",
    "artifacts": [
      {
        "location": "goldengoose",
        "metadata": {
          "account": "default"
        },
        "name": "goldengoose-build",
        "reference": "goldengoose-build-v007",
        "type": "kubernetes/Build",
        "version": "v007"
      }
    ], ...

How can I access the reference field of this artifact in an upstream stage and template it into a Kubernetes deploy manifest stage? I am trying to do something like the following in the manifest source:

${#stage("Build")["context"]["artifacts"]["0"]["reference"]}

but the required value isn't being replaced. Is there a way to get this to work?

-- dippynark
kubernetes
spinnaker

1 Answer

7/2/2019

Replace ["0"] with [0] - it is an index of array.

-- RocketRaccoon
Source: StackOverflow