Receiving artifacts from GitHub

Trigger pipelines based on commits to a GitHub repository, and inject changed GitHub files as artifacts.

Overview

This functionality uses GitHub Webhooks for delivering messages to Spinnaker and must be configured to send messages to Spinnaker’s event bus as shown below.

Prerequisites

If you (or your Spinnaker admin) have already configured Spinnaker to listen to a GitHub webhooks from the repository you plan to publish commits to, you can skip this section.

You need the following:

  • A GitHub repository either under your user or in an organization or user’s account that you have permission to publish commits to.

    This will be referred to as $ORGANIZATION/$REPOSITORY from now on (for example, spinnaker/clouddriver).

  • A running Spinnaker instance . This guide shows you how to update it to accept messages from GitHub.

  • Artifact support enabled .

At this point, we will configure GitHub webhooks and a GitHub artifact account. The webhook will be received by Spinnaker whenever a commit is made, and the artifact account will allow you to download any pertinent files.

1. Configure GitHub webhooks

Follow the GitHub webhook configuration .

2. Configure a GitHub artifact account

Follow the GitHub artifact configuration .

3. Apply your configuration changes

Once the artifact changes have been made using Halyard, run

  1. hal deploy apply

to apply them in Spinnaker.

Using GitHub artifacts in pipelines

We will need either an existing or a new pipeline that we want to be triggered on changes to GitHub artifacts. If you do not have a pipeline, create one as shown below.

You can create and edit pipelines in the Pipelines tab of Spinnaker

You can create and edit pipelines in the Pipelines tab of Spinnaker

Configure the GitHub trigger

Let’s add a Git trigger to run our pipeline. To configure the trigger:

FieldValue
Type“Git”
Repo Type“GitHub”
Organization or User$ORGANIZATION from above
Project$REPOSITORY from above
Branch(optional) Can be used (via regular expressions) to describe which branches to listen to changes one
Secret(optional) Strongly encouraged It must match the secret provided to the webhook configuration

GitHub - 图2

Configure the GitHub artifact

Now we need to declare that the GitHub trigger expects that a specific artifact matching some criteria is available before the pipeline starts executing. In doing so, you guarantee that an artifact matching your description is present in the pipeline’s execution context. If no artifact for this description is present, the pipeline won’t start.

To configure the artifact, go to the Artifact Constraints dropdown for the GitHub trigger configuration, and select “Define a new artifact…” to bring up the Expected Artifact form.

GitHub - 图3

Enter the artifact information:

  1. Enter a Display Name, or leave the autogenerated default.

  2. In the Account dropdown, select your GitHub account.

  3. Enter a value in the File path field.

    ☞ Note: This path can be a regular expression. You can, for example, set the object path to be folder/.*\.yml to trigger on any change to a YAML file inside folder in your repository.

Test the pipeline

If you add or modify a file matching your expected artifact to the configured repository, it should execute. If it doesn’t, you can start by checking the logs of the Echo service.


Last modified May 7, 2021: docs(migration): fix imgs and links (9a18ce6)