Skip to content

Pipelines

Casey Lee edited this page Oct 26, 2018 · 16 revisions

Pipelines

A pipeline can be created for each service that consists of the following steps:

  • Source - Retrieve source from GitHub for a specific branch. Triggered on each commit.
  • Build Artifact - Compile the source code via CodeBuild and a buildspec.yml.
  • Build Image - Build the Docker image and push to ECR repository.
  • Acceptance - Deploy to acceptance environment and run automated tests.
  • Production - Wait for manual approval, then deploy to production environment.

Test Automation

Define your tests in the form of CodeBuild projects. Simply create a file named buildspec-test.yml and a file named buildspec-prod.yml in your repo with the actions you'd like to take for validating the application. Additionally, you can control the CodeBuild image via the image attribute under the service.pipeline.acceptance in the mu.yml file. An example is available in the mu GitHub repo.

Configuration

---
service:

  name: my-service
  # ... service config goes here ...

  # Define the behavior of the pipeline
  pipeline:
      source:
        provider: GitHub                        # GitHub or CodeCommit (default: GitHub)
        repo: stelligent/microservice-exemplar  # The GitHub repo slug or CodeCommit repo name to build (default: none)
        branch: mu                              # The branch to build from (default: master)
      build:
        disabled: false                         # Disable the build stage of the pipeline (default: false)
        image: aws/codebuild/java:openjdk-8     # The image to use for CodeBuild job (default: aws/codebuild/ubuntu-base:latest)
        type: linuxContainer
        computeType: BUILD_GENERAL1_SMALL       # The type of compute instance for builds (default: BUILD_GENERAL1_SMALL)
      acceptance:
        disabled: false                         # Disable the acceptance stage of the pipeline (default: false)
        environment: acceptance                 # The environment name to deploy to for testing (default: acceptance)
        image: aws/codebuild/java:openjdk-8     # The image to use for CodeBuild test job (default: aws/codebuild/ubuntu-base:latest)
        type: linuxContainer
        computeType: BUILD_GENERAL1_SMALL       # The type of compute instance for testing builds (default: BUILD_GENERAL1_SMALL)
      production:
        disabled: false                         # Disable the production stage of the pipeline (default: false)
        environment: production                 # The environment name to deploy to for production (default: production)

      notify:                                   # List of email addresses to notify on pipeline results
      - joe@getmu.io
      - bob@getmu.io

      kmsKey: arn:aws....                       # The ARN of the KMS key to use for the pipeline

Commands

# List the pipelines
> mu pipeline list

# Upsert the pipeline
> mu pipeline up [-t <repo_token>]

# View the logs from the CodeBuild project in your pipeline
> mu pipeline logs [--follow] [-s <service_name>] [filter]

# Terminate the pipeline
> mu pipeline terminate [<service_name>]