首页 > 解决方案 > How can I template an artifact reference in an upstream Spinnaker stage?

问题描述

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?

标签: kubernetesspinnaker

解决方案


将 ["0"] 替换为 [0] - 它是数组的索引。


推荐阅读