我有一个大三角帆管道,上面有一个运行作业类型的(运行容器)。该配置具有要运行的映像的名称,但是标签明确指出它将在运行时解析。我创建了一个 Docker Registry 触发器,该触发器确实确实可以自行解析标签名称。当我开始手动执行时,对话框会显示一个下拉菜单供我选择标记(如果未设置 Docker Registry 触发器,则不会发生这种情况)。到目前为止, Docker Registry 和 Manual Execution 触发器都可以正常工作。
问题 出现在Webhook触发器上。我收到一条Status: TERMINAL
的消息:
No tag found for image gcr.io/xxxx in trigger context.
我尝试过在参数中传递标记。它不起作用。
答案 0 :(得分:0)
我对 webhooks + Run Job 阶段也有类似的要求,使用 spinnaker 表达式就可以了。
按照以下步骤解决:
"triggers": [
{
"account": "gcr",
"enabled": true,
"expectedArtifactIds": [
"ARTIFACT_ID_PLACEHOLDER"
],
"fromTrigger": true,
"organization": "ORG_PLACEHOLDER",
"registry": "gcr.io",
"repository": "ORG_PLACEHOLDER/IMAGE_NAME_PLACEHOLDER",
"tag": "${trigger['artifacts'][0]['version']}",
"type": "docker"
},
{
"enabled": true,
"expectedArtifactIds": [
"ARTIFACT_ID_PLACEHOLDER"
],
"source": "WEBHOOK_PLACEHOLDER",
"type": "webhook"
}
]
"expectedArtifacts": [
{
"defaultArtifact": {},
"displayName": "gcr.io/ORG_PLACEHOLDER/IMAGE_NAME_PLACEHOLDER",
"id": "ARTIFACT_ID_PLACEHOLDER",
"matchArtifact": {
"artifactAccount": "docker-registry",
"id": "MATCH_ARTIFACT_ID_PLACEHOLDER",
"name": "gcr.io/ORG_PLACEHOLDER/IMAGE_NAME_PLACEHOLDER",
"type": "docker/image"
},
"useDefaultArtifact": true,
"usePriorArtifact": false
}
]
"imageDescription": {
"account": "gcr",
"fromTrigger": false,
"imageId": "gcr.io/ORG_PLACEHOLDER/IMAGE_NAME_PLACEHOLDER:${trigger['artifacts'][0]['version']}",
"registry": "gcr.io",
"repository": "gcr.io/ORG_PLACEHOLDER/IMAGE_NAME_PLACEHOLDER",
"tag": "${trigger['artifacts'][0]['version']}"
}
最终 JSON:
{
"appConfig": {},
"expectedArtifacts": [
{
"defaultArtifact": {},
"displayName": "gcr.io/ORG_PLACEHOLDER/IMAGE_NAME_PLACEHOLDER",
"id": "ARTIFACT_ID_PLACEHOLDER",
"matchArtifact": {
"artifactAccount": "docker-registry",
"id": "MATCH_ARTIFACT_ID_PLACEHOLDER",
"name": "gcr.io/ORG_PLACEHOLDER/IMAGE_NAME_PLACEHOLDER",
"type": "docker/image"
},
"useDefaultArtifact": true,
"usePriorArtifact": false
}
],
"keepWaitingPipelines": false,
"lastModifiedBy": "",
"limitConcurrent": true,
"spelEvaluator": "v4",
"stages": [
{
"account": "ACCOUNT_PLACEHOLDER",
"annotations": {},
"application": "APPLICATIONNAME_PLACEHOLDER",
"cloudProvider": "kubernetes",
"cloudProviderType": "kubernetes",
"containers": [
{
"args": [],
"command": [],
"envFrom": [],
"envVars": [],
"imageDescription": {
"account": "gcr",
"fromTrigger": false,
"imageId": "gcr.io/ORG_PLACEHOLDER/IMAGE_NAME_PLACEHOLDER${trigger['artifacts'][0]['version']}",
"registry": "gcr.io",
"repository": "gcr.io/ORG_PLACEHOLDER/IMAGE_NAME_PLACEHOLDER",
"tag": "${trigger['artifacts'][0]['version']}"
},
"imagePullPolicy": "ALWAYS",
"limits": {},
"name": "CONTAINER_NAME_PLACEHOLDER",
"ports": [
{
"containerPort": 80,
"name": "http",
"protocol": "TCP"
}
],
"requests": {},
"volumeMounts": []
}
],
"dnsPolicy": "ClusterFirst",
"expectedArtifacts": [
{
"defaultArtifact": {},
"displayName": "gcr.io/ORG_PLACEHOLDER/IMAGE_NAME_PLACEHOLDER",
"id": "ARTIFACT_ID_PLACEHOLDER",
"matchArtifact": {
"artifactAccount": "docker-registry",
"id": "MATCH_ARTIFACT_ID_PLACEHOLDER",
"name": "gcr.io/ORG_PLACEHOLDER/IMAGE_NAME_PLACEHOLDER",
"type": "docker/image"
},
"useDefaultArtifact": false,
"usePriorArtifact": false
}
],
"labels": {},
"name": "STAGE_NAME_PLACEHOLDER",
"namespace": "default",
"nodeSelector": {},
"refId": "1",
"requisiteStageRefIds": [],
"serviceAccountName": "",
"type": "runJob",
"volumeSources": []
}
],
"triggers": [
{
"account": "gcr",
"enabled": true,
"expectedArtifactIds": [
"ARTIFACT_ID_PLACEHOLDER"
],
"fromTrigger": true,
"organization": "ORG_PLACEHOLDER",
"registry": "gcr.io",
"repository": "ORG_PLACEHOLDER/IMAGE_NAME_PLACEHOLDER",
"tag": "${trigger['artifacts'][0]['version']}",
"type": "docker"
},
{
"enabled": true,
"expectedArtifactIds": [
"ARTIFACT_ID_PLACEHOLDER"
],
"source": "WEBHOOK_PLACEHOLDER",
"type": "webhook"
}
],
"updateTs": ""
}
注意:在上述 JSON 配置中根据您的要求替换 XXXX_PLACEHOLDER,例如“ORG_PLACEHOLDER”、“IMAGE_NAME_PLACEHOLDER”等。