Steps

Pipeline steps are defined as a series of shell commands. The commands are executed inside the root directory of your git repository. The root of your git repository, also called the workspace, is shared by all steps in your pipeline.

Example configuration:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
kind: pipeline
type: digitalocean
name: default

steps:
- name: backend
  commands:
  - go build
  - go test

- name: frontend
  commands:
  - npm install
  - npm test

Commands

The commands are executed inside the root directory of your git repository. The root of your git repository, also called the workspace, is shared by all steps in your pipeline. This allows file artifacts to persist between steps.

5
6
7
8
9
steps:
- name: backend
  commands:
  - go build
  - go test

The above commands are converted to a simple shell script. The commands in the above example are roughly converted to the below script:

1
2
3
4
5
6
#!/bin/sh
set -e
set -x

go build
go test

The exit code is used to determine whether the step is passing or failing. If a command returns a non-zero exit code, the step is marked as failing. The overall pipeline status is also marked as failing, and remaining pipeline steps are skipped (unless explicitly configured to run on failure).

Environment

The environment section provides the ability to define environment variables scoped to individual pipeline steps.

 5
 6
 7
 8
 9
10
11
12
steps:
- name: backend
  environment:
    GOOS: linux
    GOARCH: amd64
  commands:
  - go build
  - go test

Conditions

The when section provides the ability to conditionally limit the execution of steps at runtime. The below example limits step execution by branch, however, you can limit execution by event, reference, status and more.

 5
 6
 7
 8
 9
10
11
12
steps:
- name: backend
  commands:
  - go build
  - go test
  when:
    branch:
    - master

Use the status condition to override the default runtime behavior and execute steps even when the pipeline status is failure:

 5
 6
 7
 8
 9
10
11
12
steps:
- name: cleanup
  commands:
  - docker system prune -f
  when:
    status:
    - failure
    - success

See the Conditions article for additional details:

Conditions

Failure

The failure attribute lets you customize how the system handles failure of an individual step. This can be useful if you want to allow a step to fail without failing the overall pipeline.

 5
 6
 7
 8
 9
10
steps:
- name: backend
  failure: ignore
  commands:
  - go build
  - go test