英文:
Couldn't create spinnaker pipeline template which runs another pipeline
问题
In the above template, you are referring to the pipeline ID. To make it dynamic and templated, you can use Spinnaker's expression language. Here's an example of how you can modify the pipeline JSON:
在上述模板中,您正在引用管道ID。要使其动态和可模板化,您可以使用Spinnaker的表达式语言。以下是如何修改管道JSON的示例:
{
...
{
"application": "app-stack",
"failPipeline": true,
"name": "Run pipeline",
"pipeline": "${trigger['resolvedPipelineId']}", // Use an expression here
"pipelineParameters": {},
"refId": "6",
"requisiteStageRefIds": [
"5"
],
"type": "pipeline",
"waitForCompletion": true
}
...
}
In this modified JSON, I've used the ${trigger['resolvedPipelineId']}
expression to make the pipeline
field dynamic. You can set resolvedPipelineId
dynamically when triggering the pipeline, and it will replace ${trigger['resolvedPipelineId']}
during runtime.
英文:
I am new to spinnaker and started writing pipeline templates for all tools and applications in our organization. In one scenario I have to run a pipeline from another pipeline and I want both pipelines to need to be templated so that I can create pipelines based on the deployment environment.
But when I am referring the pipeline from the calling pipeline I have to map the ID of the pipeline.
{
...
{
"application": "app-stack",
"failPipeline": true,
"name": "Run pipeline",
"pipeline": "615da201-9652-4ce2-8039-21163d5f99d4",
"pipelineParameters": {},
"refId": "6",
"requisiteStageRefIds": [
"5"
],
"type": "pipeline",
"waitForCompletion": true
}
],
"triggers": [],
"updateTs": "1578057441000"
}
}
In the above template, I am referring to the pipeline ID. But how can I make it to dynamic so that it can be templated.
答案1
得分: 2
"Template it as "${#pipelineId("pipeline_name")}"
this will return the pipeline Id in UUID format." 可以翻译为:"将其模板化为 "${#pipelineId("pipeline_name")}"
,这将返回以UUID格式表示的管道ID。"
英文:
Template it as "${#pipelineId("pipeline_name")}"
this will return the pipeline Id in UUID format.
答案2
得分: 1
在我们的公司中,我们避免使用管道模板,只使用sponnet。它帮助我们提供有意义的标识符,可以轻松从任何地方引用,并且可以动态创建。因此,例如,您可以使pipeline
和name
相等。阶段的标识符也一样。
从您的问题中不清楚您遇到了什么问题。您不需要在 JSON 中指定管道标识符来引用它,只需要名称。要执行某些操作与您的子管道,通常只需要application
和executionId
,可能还需要stage.id
。
英文:
In our company we are avoided pipeline templates and uses sponnet only. It helps us to provide meaningful ids which are easy to refer from anywhere and could be dynamically created. So as result you can make pipeline
and name
be equal for example. Same for the stage's ids applied.
From your question not clear what issue do you have. You don't need to specify pipeline id in json to refer to it, only name. For performing some actions with your child pipeline you usually need only application
and executionId
and may be stage.id
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论