Docs Navigation

Available Environment Variables

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

Name Value
CI true
SEMAPHORE true
BRANCH_NAME Eg. master
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_THREAD_RESULT Eg. failed
SEMAPHORE_CURRENT_THREAD Eg. 1
SEMAPHORE_THREAD_COUNT Eg. 4
SEMAPHORE_TRIGGER_SOURCE Eg. push, manual, api, scheduler

Variables available only for pull requests:

Name Value
PULL_REQUEST_NUMBER Eg. 121

Variables available only during deployment:

Name Value
SEMAPHORE_DEPLOY_NUMBER Eg. 17
SEMAPHORE_SERVER_NAME Eg. staging
DEPLOY_AUTHOR_NAME Semaphore username or commit author
HEROKU_API_KEY Eg. 12139243 - when deploying to Heroku

Semaphore sets the following locale:

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

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

You can find more information about available databases on Semaphore here.

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-2017 © Rendered Text. All rights reserved. Terms of Service, Privacy policy, Security.