0

I have a Spinnaker Pipeline with a single stage on it of type Run Job (Runs a container). This configuration has the name of the image to by ran, but the tag specifically says it will be resolved at runtime. I created a Docker Registry trigger that does indeed resolves the tag name by itself. When I Start a manual Execution, the dialog shows a dropdown for me to select the tag (this doesn't happen if the Docker Registry trigger is not setup). Until this point, both Docker Registry and Manual Execution triggers work fine.

The problem arises on the webhook trigger. I get a Status: TERMINAL with the message:

No tag found for image gcr.io/xxxx in trigger context.

I have tried passing the tag in the parameters. It doesn't work.

eriel marimon
  • 1,230
  • 1
  • 19
  • 29

2 Answers2

0

It happens because webhook trigger does not provide any docker artifact for your pipeline.

To solve it you may provide default artifact.

Second option is to supply an artifact description through webhook. Add you docker artifact to "Artifact Constraints " in Spinnaker:


  "expectedArtifacts": [
    {
      "displayName": "docker-image",
      "id": "artifact-id",
      "matchArtifact": {
        "id": "match-artifact-id",
        "type": "docker/image"
      },
      "useDefaultArtifact": false,
      "usePriorArtifact": false
    }
  ]

...

    {
      "enabled": true,
      "expectedArtifactIds": [
        "artifact-id"
      ],
      "payloadConstraints": {},
      "source": "test",
      "type": "webhook"
    }

and add payload to you request:

POST http://spinnaker.cluster.local/webhooks/webhook/test
Content-Type: application/json

{
  "artifacts": [
    {
      "name": "docker-registry.local/org/app",
      "reference": "docker-registry.local/org/app:1.0.0",
      "type": "docker/image",
      "version": "1.0.0"
    }
  ]
}
RocketRaccoon
  • 2,559
  • 1
  • 21
  • 30
0

I also had a similar requirement for webhooks + Run Job stage, using spinnaker expressions did the trick.

Resolved it by following these steps:

  1. Add both automated triggers - Docker registry and Webhooks
"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"
    }
  ]
  1. Add expectedArtifacts
"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
    }
  ]
  1. Update imageDescription
    "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']}"
    }

Final 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": ""
}

Note: Replace XXXX_PLACEHOLDER such as 'ORG_PLACEHOLDER', 'IMAGE_NAME_PLACEHOLDER' etc as per your requirement in the above JSON configurations.