Skip to content

Latest commit

 

History

History
216 lines (137 loc) · 7.08 KB

environment-variables_5b16f4a30428632c466a94c6.md

File metadata and controls

216 lines (137 loc) · 7.08 KB

Overview

This document describes the environment variables used in Semaphore 2.0 projects.

Although some of the presented environment variables are defined on a per project or on a per task basis, all the presented environment variables can be seen on a per job basis.

Predefined environment variables

Semaphore defines and uses its own environment variables.

Semaphore related

This group of environment variables includes the environment variables that are related to Semaphore 2.0 and hold information that is specific to Semaphore 2.0.

CI

The value of the CI environment variable specifies whether we are in a Continuous Integration environment or not. The type of the CI variable is boolean.

Example value: true

SEMAPHORE

The value of the SEMAPHORE environment variable says whether the job is executed in the Semaphore 2.0 environment or not and is a boolean variable.

Example value: true

SEMAPHORE_PROJECT_NAME

The value of the SEMAPHORE_PROJECT_NAME environment variable holds the name of the project a job belongs to.

Example value: Documentation Project

SEMAPHORE_PROJECT_ID

The value of the SEMAPHORE_PROJECT_ID environment variable holds the project ID of the project that a job belongs to.

Example value: 0dd982e8-32f5-4037-983e-4de01ac7fb1e

SEMAPHORE_JOB_NAME

The value of the SEMAPHORE_JOB_NAME environment variable is a string that holds the name of the job.

Example value: Push image to Docker

SEMAPHORE_JOB_ID

The SEMAPHORE_JOB_ID environment variable holds the Job ID of the job that is being executed. It is the same value as is displayed in the output of the sem get jobs or the sem get jobs --all commands and is assigned by Semaphore 2.0.

Example value: a26d42cf-89ac-4c3f-9e2d-51bb231897bf

SEMAPHORE_JOB_RESULT

The value of the SEMAPHORE_JOB_RESULT environment variable holds the result of a job. The list of values includes none, passed, failed and stopped.

Example value: passed

SEMAPHORE_WORKFLOW_ID

The value of the SEMAPHORE_WORKFLOW_ID environment variable is the ID of the workflow of the current job.

The SEMAPHORE_WORKFLOW_ID environment variable remains the same during a pipeline run and is available in all the blocks of a pipeline as well as in all promoted and auto promoted pipelines.

Example value: 65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf

SEMAPHORE_PIPELINE_ID

The value of the SEMAPHORE_PIPELINE_ID environment variable is the pipeline ID that is used for the execution of the active job.

The SEMAPHORE_PIPELINE_ID environment variable remains the same throughout all the blocks of a pipeline, which makes it the perfect candidate for sharing data inside the same pipeline.

Example value: ea3e6bba-d19a-45d7-86a0-e78a2301b616

SEMAPHORE_PIPELINE_ARTEFACT_ID

The value of the SEMAPHORE_PIPELINE_ARTEFACT_ID environment variable is used internally by Semaphore 2.0.

The SEMAPHORE_PIPELINE_ARTEFACT_ID environment variable always exists. Its value is the same as the value of the SEMAPHORE_PIPELINE_X_ARTEFACT_ID environment variables, where X is the biggest number among all the SEMAPHORE_PIPELINE_X_ARTEFACT_ID environment variables of a given pipeline.

So, in the pipeline that is initiated by .semaphore/semaphore.yml, you will have both SEMAPHORE_PIPELINE_ARTEFACT_ID and SEMAPHORE_PIPELINE_0_ARTEFACT_ID and their values will be the same.

Example value: 83360523-5359-4c79-adcd-41a80ec67815

SEMAPHORE_PIPELINE_0_ARTEFACT_ID

The value of the SEMAPHORE_PIPELINE_0_ARTEFACT_ID environment variable is used internally by Semaphore 2.0.

The SEMAPHORE_PIPELINE_0_ARTEFACT_ID environment variable always exists and always points to the SEMAPHORE_PIPELINE_ARTEFACT_ID value of the pipeline created by .semaphore/semaphore.yml.

Example value: 83360523-5359-4c79-adcd-41a80ec67815

SEMAPHORE_PIPELINE_1_ARTEFACT_ID

The SEMAPHORE_PIPELINE_1_ARTEFACT_ID environment variable will only appear if there is at least one promotion in a pipeline. This means that it will begin appearing in the first promoted pipeline.

The numbering and the creation of new ARTEFACT_ID environment variables will continue for as long as there exist more promotions in a pipeline. This means that you might have SEMAPHORE_PIPELINE_2_ARTEFACT_ID, SEMAPHORE_PIPELINE_3_ARTEFACT_ID, SEMAPHORE_PIPELINE_4_ARTEFACT_ID, etc, depending on the number of promotions that exist.

As the numbering begins with 0, the 10th pipeline will have a SEMAPHORE_PIPELINE_9_ARTEFACT_ID environment variable.

Git repository related

This group of environment variables includes environment variables that are used by Semaphore 2.0 and are related to GitHub and the GitHub repository that is used in the current Semaphore 2.0 project.

SEMAPHORE_GIT_SHA

The value of the SEMAPHORE_GIT_SHA environment variable holds the current revision of code that the pipeline is using.

Example values: 5c84719708b9b649b9ef3b56af214f38cee6acde, HEAD

SEMAPHORE_GIT_URL

The value of the SEMAPHORE_GIT_URL environment variable is the URL of the GitHub repository used in the current Semaphore 2.0 project.

Example value: http://git@github.com:semaphoreci/toolbox.git

SEMAPHORE_GIT_BRANCH

The value of the SEMAPHORE_GIT_BRANCH environment variable is the name of the GitHub branch that is used in the current job.

Example value: development

SEMAPHORE_GIT_REPO_NAME

The value of the SEMAPHORE_GIT_REPO_NAME environment variable is the name of the GitHub repository used in the current Semaphore 2.0 project.

Example value: toolbox

SEMAPHORE_GIT_DIR

The value of the SEMAPHORE_GIT_DIR environment variable is the name of the directory that contains the files of the GitHub repository of the current Semaphore 2.0 project.

Example value: foo

Cache related

The following environment variables are related to the cache utility. You can find more information about the cache utility at Toolbox reference.

SEMAPHORE_CACHE_USERNAME

The value of the SEMAPHORE_CACHE_USERNAME environment variable is the username that will be used for connecting to the cache server.

Example value: 0614ef08af7a408d8aae45b029ba3bb8

SEMAPHORE_CACHE_URL

The value of the SEMAPHORE_CACHE_URL environment variable is the IP address and the port number of the cache server.

Example value: 94.130.158.146:29920

SEMAPHORE_CACHE_PRIVATE_KEY_PATH

The value of the SEMAPHORE_CACHE_PRIVATE_KEY_PATH environment variable is the path to the file that contains the SSH key to the cache server.

Example value: /home/semaphore/.ssh/semaphore_cache_key

See Also