Workspace

Drone automatically creates a temporary volume, known as your workspace, where it clones your repository. The workspace is the current working directory for each step in your pipeline.

Because the workspace is a volume, filesystem changes are persisted between pipeline steps. In other words, individual steps can communicate and share state using the filesystem.

Workspace path inside your pipeline containers:

/drone/src

Customizing the Workspace

You can customize the workspace directory by defining the workspace section in your yaml. Here is a basic example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
kind: pipeline
type: docker
name: default

workspace:
  base: /go
  path: src/github.com/octocat/hello-world

steps:
- name: backend
  image: golang:latest
  commands:
  - go get
  - go test

- name: frontend
  image: node:latest
  commands:
  - npm install
  - npm run tests

This would be equivalent to the following docker commands:

$ docker volume create my-named-volume
$ docker run --volume=my-named-volume:/go golang:latest
$ docker run --volume=my-named-volume:/go node:latest

The base attribute defines a shared base volume available to all pipeline steps. This ensures your source code, dependencies and compiled binaries are persisted and shared between steps.

1
2
3
4
5
6
7
kind: pipeline
type: docker
name: default

workspace:
  base: /go
  path: src/github.com/octocat/hello-world

The path attribute defines the working directory of your build. This is where your code is cloned and will be the default working directory of every step in your build process. The path must be relative and is combined with your base path.

1
2
3
4
5
6
7
kind: pipeline
type: docker
name: default

workspace:
  base: /go
  path: src/github.com/octocat/hello-world

Example clone path when using the above configuration:

$ git clone https://github.com/octocat/hello-world \
  /go/src/github.com/octocat/hello-world