Skipping Build Steps

by bradrydzewski

Limit the execution of any pipeline step at runtime using the when block:

pipeline:
  slack:
    image: plugins/slack
    channel: dev
+   when:
+     branch: master

Branches

Execute a step if the branch is master or develop:

when:
  branch: [master, develop]

Execute a step if the branch is starts with prefix/*:

when:
  branch: prefix/*

Execute a step using custom include and exclude logic:

when:
  branch:
    include: [ master, release/* ]
    exclude: [ release/1.0.0, release/1.1.* ]

Events

Execute a step if the build event is a tag:

when:
  event: tag

Execute a step for all non-pull request events (default):

when:
  event: [push, tag, deployment]

Execute a step for all build events:

when:
  event: [push, pull_request, tag, deployment]

Status

Execute a step when the build status changes:

when:
  status: changed

Execute a step when the build is passing or failing:

when:
  status:  [ failure, success ]

Platform

Execute a step for a specific platform:

when:
  platform: linux/amd64

Execute a step for a specific platform using wildcards:

when:
  platform:  [ linux/*, windows/amd64 ]

Environment

Execute a step for deployment events matching the target deployment environment:

when:
  environment: production
  event: deployment

Matrix

Execute a step for a single matrix permutation:

when:
  matrix:
    GO_VERSION: 1.5
    REDIS_VERSION: 2.8