ci_diff_helper.circle_ci module¶
Set of utilities for dealing with Circle CI.
This module provides a custom configuration type
CircleCI
for the CircleCI CI system.
This module uses a selection of environment variables to detect
the state of Circle CI configuration. See
environment_vars
for more details.
CircleCI
Configuration Type¶
When running in CircleCI, you can automatically detect your current environment and get the configuration object:
>>> import ci_diff_helper
>>> config = ci_diff_helper.get_config()
>>> config
<CircleCI (active=True)>
To use the CircleCI
configuration type directly:
>>> config = ci_diff_helper.CircleCI()
>>> config
<CircleCI (active=True)>
>>> config.branch
'master'
>>> config.tag
'0.4.2'
>>> config.repo_url
'https://github.com/organization/repository'
>>> config.provider
<CircleCIRepoProvider.github: 'github'>
>>> config.slug
'organization/repository'
During a pull request build, we can determine information about the current PR being built:
>>> config = ci_diff_helper.CircleCI()
>>> config
<CircleCI (active=True)>
>>> config.in_pr
True
>>> config.pr
23
>>> config.branch
'pull/23'
>>> config.base
'7450ebe1a2133442098faa07f3c2c08b612d75f5'
-
class
ci_diff_helper.circle_ci.
CircleCI
[source]¶ Bases:
ci_diff_helper._config_base.Config
Represent CircleCI state and cache return values.
-
active
¶ bool – Indicates if currently running in the target CI system.
-
base
¶ str – The
git
object that current build is changed against.The
git
object can be any of a branch name, tag, a commit SHA or a special reference.Warning
This property will currently only work in a build for a pull request from a GitHub repository.
-
branch
¶ bool – Indicates the current branch in the target CI system.
This may indicate the active branch or the base branch of a pull request.
-
in_pr
¶ bool – Indicates if currently running in CircleCI pull request.
This uses the
CIRCLE_PR_NUMBER
environment variable to check if currently in a pull request.
-
is_merge
¶ bool – Indicates if the HEAD commit is a merge commit.
-
pr
¶ int – The current CircleCI pull request (if any).
If there is no active pull request, returns
None
.
-
provider
¶ str – The code hosting provider for the current CircleCI build.
-
repo_url
¶ str – The URL of the current repository being built.
For example:
https://github.com/{organization}/{repository}
orhttps://bitbucket.org/{user}/{repository}
.
-
slug
¶ str – The current slug in the CircleCI build.
Of the form
{organization}/{repository}
.
-
tag
¶ str – The
git
tag of the current CI build.
-