Docs Navigation

Available Environment Variables

Semaphore exports different environment variables depending on your setup and whether it's a build or a deploy. These are different environment variables that are exported:

# Variables exported in builds and deploys

Before running your build or deploy, Semaphore exports the following environment variables:

Name Value
CI true
SEMAPHORE true
BRANCH_NAME Eg. master, pull-request-7
REVISION Eg. 6375073ec483bd2d949fad188d1ab869
WKHTMLTOPDF_PATH /usr/local/bin/wkhtmltopdf
SEMAPHORE_PROJECT_DIR Eg. /home/runner/my_app
SEMAPHORE_CACHE_DIR Eg. /home/runner/my_app/.semaphore-cache
SEMAPHORE_PROJECT_HASH_ID Eg. 18670db3bd1c017cb5fc6013bec1d75d3
SEMAPHORE_PROJECT_NAME Eg. Base-app
SEMAPHORE_BRANCH_ID Eg. 85726
SEMAPHORE_BUILD_NUMBER Eg. 23
SEMAPHORE_REPO_SLUG Eg. rastasheep/my_project
SEMAPHORE_JOB_RESULT Eg. failed
SEMAPHORE_CURRENT_JOB Eg. 1
SEMAPHORE_JOB_COUNT Eg. 4
SEMAPHORE_TRIGGER_SOURCE Eg. push, manual, api, scheduler

# Variables available only for pull requests originating from forks:

Name Value
PULL_REQUEST_NUMBER Eg. 121

# Variables available in deploys only

Name Value
SEMAPHORE_DEPLOY_NUMBER Eg. 17
SEMAPHORE_SERVER_NAME Eg. staging
DEPLOY_AUTHOR_NAME Semaphore username or commit author

# Variables exported in deployment integrations

Semaphore offers multiple deployment integrations to make it easy to deploy to your provider. These are exported during deploy phase of your project.

# Common AWS Variables

These variables are exported in all AWS deployment integrations.

Name Value
AWS_ACCESS_KEY_ID Eg. 123kjsfa1902rl
AWS_SECRET_ACCESS_KEY Eg. as9tr813kjfgasll2123kjsfa1902rl
AWS_DEFAULT_REGION Eg. us-west-2

# AWS Elastic Beanstalk Variables

Together with the common AWS variables, Semaphore exports also these variables:

Name Value
S3_BUCKET_NAME Eg. my-bucket - name of the bucket where your application zip file will be uploaded
EB_APP_NAME Eg. my-elasticbeanstalk-app - application name you're deploying to on Elastic Beanstalk
EB_ENV_NAME Eg. production - name of the environment you're deploying to on Elastic Beanstalk
EB_DB_ADAPTER Eg. pg - type of the database you're using on Elastic Beanstalk
EB_DB_ENV Eg. production - name of the database environment you're deploying to on Elastic Beanstalk

# AWS S3 Variables

Together with the common AWS variables, Semaphore exports also these variables:

Name Value
S3_BUCKET_NAME Eg. my-bucket - name of the bucket where your application zip file will be uploaded
S3_INDEX_DOC Eg. index.html - entry point of your S3 website
S3_DIRECTORY Eg. docs - name of the directory you want to upload from your repository to S3

# AWS Lambda Variables

Together with the common AWS variables, Semaphore exports also this variable:

Name Value
LAMBDA_FUNCTION_NAME Eg. my-cool-function - name of the function on AWS Lambda

# Heroku

Name Value
HEROKU_API_KEY Eg. 12139243 - when deploying to Heroku

# Locale variables

Semaphore sets the following locale:

Name Value
LANG en_US.UTF-8
LC_ALL en_US.UTF-8

# Variables in Ruby projects with databases

The following variables are available to Ruby projects with selected MySQL or PostgreSQL database in project settings. The same values are used in config/database.yml that is automatically generated for your project. You can also use them in any custom script that your build depends on:

Name Value
DATABASE_USERNAME runner
DATABASE_NAME_DEVELOPMENT Eg. 18671ad3b3r7bec1d75d3_development
DATABASE_NAME_TEST Eg. 18671ad3b3rVa5fc6017bec1d75d3_test
DATABASE_PASSWORD semaphoredb

If you need to create and manage custom database setup you can use following environment variables as credentials:

Name Value
DATABASE_MYSQL_USERNAME root
DATABASE_MYSQL_PASSWORD semaphoredb
DATABASE_POSTGRESQL_USERNAME runner
DATABASE_POSTGRESQL_PASSWORD semaphoredb

Rails users, note that Semaphore does not set RAILS_ENV or RACK_ENV. On one occasion we did start setting them to "test" but too many projects experienced unexpected problems.

Semaphore Docs are open source — Edit on GitHub

Newsletter

Occasional lightweight product and blog updates. Unsubscribe at any time.

2009-2018 © Rendered Text. All rights reserved. Terms of Service, Privacy policy, Security.