Using the environment

Pipeline CI/CD gives us the ability to define environment variables scoped to individual build steps. Here's an example of a pipeline step with custom environment variables:

pipeline:
  build:
    image: golang
+   environment:
+     - CGO=0
+     - GOOS=linux
+     - GOARCH=amd64
    commands:
      - go build
      - go test

Please note that you cannot expand environment variables in the environment section. If you need to expand variables they should be exported in the commands section.

pipeline:
  build:
    image: golang
-   environment:
-     - PATH=$PATH:/go
    commands:
+     - export PATH=$PATH:/go
      - go build
      - go test

Global environment variables

This is a list of all the environment variables available in your build environment. These are injected into your build and plugins containers. See, Templates.

To make it easy to use plugins made for Drone, the variables prefixed with CICD_ are available with the DRONE_ prefix as well.

Pipeline specific environment variables

NAME DESC
CLUSTER_NAME Pipeline cluster name where the build is running
ORG_NAME Pipeline organization name where the build belongs
DOMAIN_NAME Pipeline domain registered for this build

General environment variables

NAME DESC
CI=cicd environment is Pipeline CI/CD
CICD=true environment is Pipeline CI/CD
CICD_ARCH environment architecture (linux/amd64)
CICD_REPO repository full name (banzaicloud/pipeline)
CICD_REPO_OWNER repository owner
CICD_REPO_NAME repository name
CICD_REPO_SCM repository scm (git)
CICD_REPO_LINK repository link
CICD_REPO_AVATAR repository avatar
CICD_REPO_BRANCH repository default branch (master)
CICD_REPO_PRIVATE repository is private
CICD_REPO_TRUSTED repository is trusted
CICD_REMOTE_URL repository clone url
CICD_COMMIT_SHA commit sha
CICD_COMMIT_REF commit ref
CICD_COMMIT_BRANCH commit branch
CICD_COMMIT_LINK commit link in remote
CICD_COMMIT_MESSAGE commit message
CICD_COMMIT_AUTHOR commit author username
CICD_COMMIT_AUTHOR_EMAIL commit author email address
CICD_COMMIT_AUTHOR_AVATAR commit author avatar
CICD_BUILD_NUMBER build number
CICD_BUILD_EVENT build event (push, pull_request, tag)
CICD_BUILD_STATUS build status (success, failure)
CICD_BUILD_LINK build result link
CICD_BUILD_CREATED build created unix timestamp
CICD_BUILD_STARTED build started unix timestamp
CICD_BUILD_FINISHED build finished unix timestamp
CICD_PREV_BUILD_STATUS prior build status
CICD_PREV_BUILD_NUMBER prior build number
CICD_PREV_COMMIT_SHA prior build commit sha
CICD_JOB_NUMBER job number
CICD_JOB_STATUS job status
CICD_JOB_STARTED job started
CICD_JOB_FINISHED job finished
CICD_BRANCH commit branch
CICD_COMMIT commit sha
CICD_TAG commit tag
CICD_PULL_REQUEST pull request number
CICD_DEPLOY_TO deployment target (e.g. production)
CICD_NAMESPACE the Kubernetes namespace where the build is running