Setting up Google Cloud Build as a Continuous Integration (CI) system within Spinnaker enables triggering pipelines when builds complete.
gcloud services enable cloudbuild.googleapis.com
Configure Spinnaker to Listen for Google Cloud Build Pub/Sub Notifications
Google Cloud Build sends Build Notifications when the state of your build changes. You can create a pipeline trigger to invoke a pipeline based on the status of your build.
Create a Subscription object for the
cloud-buildstopic in your project:
PROJECT_ID= SUBSCRIPTION_NAME=gCloudBuilds gcloud pubsub subscriptions create $SUBSCRIPTION_NAME \ --topic projects/$PROJECT_ID/topics/cloud-builds \ --project $PROJECT_ID
Configure and deploy Spinnaker via Halyard with your newly created subscription.
hal config pubsub google subscription add $SUBSCRIPTION_NAME \ --project $PROJECT_ID \ --subscription-name $SUBSCRIPTION_NAME \ --message-format GCB hal config pubsub google enable hal deploy apply
Configure Your Pipeline Trigger
In your Pipeline configuration, click the Configuration stage on the far left of the pipeline diagram.
Click Automated Triggers.
In the Type field, select
In the Pub/Sub System Type field, select
In the Subscription Name field, select your
In the Attribute Constraints field, enter
statusin the Key, and
SUCCESS(all upper case) in the Value field.
In the Payload Constraints field, you can enter any of the top-level fields from the Build object documentation as the key, and a Java regular expression as the value.
In the Expected Artifacts field, you can add any build artifacts as expected artifacts. For example, if the build produces a Docker image, you can add an expected artifact of type Docker with a value of
my-applicationwith appropriate values). You can then use the produced image in downstream stages.