candis/circleci

By candis

Updated over 4 years ago

A container with useful helpers for CircleCI 2.0

Image
1

50K+

CANDIS CircleCI helper image CircleCIMaintainability

The purpose of this image is to make interacting with CircleCI 2.0 easier, and provide a few opinionated suggestions on how to best run CI pipelines.

In order to use this image, please use it as the starter image in your CircleCI config file (.circleci/config.yml):

docker:
  - image: candis/circleci:$VERSION

...where VERSION equals the version you want to use. Hint: its value is located in the VERSION file in this repo.

Custom helper commands

build_helm_package

build_helm_package is a helper to package a helm chart. The assumpted directory structure is described here. Additionally the following environment variables need to be present: AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_ECR_ACCOUNT_URL.

In order to use build_helm_package, just add it as a step to your CircleCI config file:

- run:
    name: Build Helm package
    command: build_helm_package
build_push_image

build_push_image is a helper to build and push an image to an AWS ECR Docker registry. It assumes a Dockerfile to be present in the root of the repository and the following environment variables to be present: AWS_ACCOUNT_ID, AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_ECR_ACCOUNT_URL. In addition, GITHUB_ACCESS_TOKEN needs to be present if dependencies are to be pulled from a private GitHub npm registry.

In order to use build_helm_package, just add it as a step to your CircleCI config file:

- run:
    name: Build and push the Docker image to AWS ECR
    command: build_push_image
jira_notify

jira_notify reports the status of builds and deployments to JIRA by parsing ticket references from commit messages. More info on the actual JIRA feature can be found here. For this feature to work you need to add an environment variable called CIRCLE_TOKEN that includes a CircleCI token with full permission scope to the CircleCI project and enable the JIRA integration (repo settings -> permissions -> JIRA integration (use token method)).

NameDescriptionValues
ENVIRONMENT_TYPEIndicates the category of target environment as defined by Atlassiandevelopment, testing or production
JOB_TYPEIndicates if job should be treated as build or deployment in Jira dev panel. Note that Deployments require additional detailsbuild or deployment
- run:
    name: Notify Jira about new production release
    command: jira_notify
    environment:
      ENVIRONMENT_TYPE: 'production'
      JOB_TYPE: 'deployment'
security_check

security_check is a helper to run an automated security scanner to look for known JS/Node.js vulnerabilities.

In order to use security_check, just add it as a step to your CircleCI config file:

- run:
    name: Security Check
    command: security_check
start_deployment_pipeline

start_deployment_pipeline is a helper to start the repository Spinnaker deployment pipeline via API.

In order to use start_deployment_pipeline, just add it as a step to your CircleCI config file and ensure that the platform-deployment context is available:

- run:
    name: Start deployment pipeline
    command: start_deployment_pipeline
sync_spinnaker_config[DEPRECATED - use sync_infra_configs instead]

sync_spinnaker_config is a helper to synchronise the repository spinnaker code config to the actual running Spinnaker deployment.

In order to use sync_spinnaker_config, just add it as a step to your CircleCI config file and ensure that the platform-deployment context is available:

- run:
    name: Sync Spinnaker config
    command: sync_spinnaker_config
sync_infra_configs

sync_infra_configs is a helper to synchronise all service infrastructure configuration to related tools based on a single project.yaml file within a service's _infra directory. This currently includes application and deployment pipeline configs for Spinnaker.

In order to use sync_spinnaker_config, just add it as a step to your CircleCI config file and ensure that the platform-deployment context is available:

- run:
    name: Sync project infrastructure configs
    command: sync_infra_configs

_infra/project.yaml

This file is meant to abstract various configuration details by providing a high-level API with great defaults. Currently, this file only supports the following fields:

KeyDescription
versionThe project configuration version number. Currently there is only 1 available.
nameThe project name, used for the Spinnaker application and pipeline naming. Supports a maximum of 64 characters.
descriptionThe project description used to provide additional details within Spinnaker.

Example:

version: 1
name: service-foo-bar
description: This service is responsible for foo and bar.
deployment_type: default
tag_prod_release

tag_prod_release is a helper to tag new production releases. This currently includes tagging the corresponding Docker image as latest and later also pushing a new Git tag.

In order to use tag_prod_release, just add it as a step to your CircleCI config file and ensure that the AWS_ACCESS_KEY_ID, AWS_DEFAULT_REGION and AWS_SECRET_ACCESS_KEY environment variables are set for the CircleCI project. Use the "Import Variables" feature from the env var view to import the mentioned environment variables from the service-boilerplate repository.

- run:
    name: Tag production release
    command: tag_prod_release

Docker Pull Command

docker pull candis/circleci