All Projects → pvdlg → Env Ci

pvdlg / Env Ci

Licence: mit
Get environment variables exposed by CI services

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Env Ci

Ci Detector
Detect continuous integration environment and get information of current build
Stars: ✭ 138 (-23.33%)
Mutual labels:  appveyor, ci, continuous-integration, jenkins, circleci, travis, gitlab
Cistern
A terminal UI for Unix to monitor Continuous Integration pipelines from the command line. Current integrations include GitLab, Azure DevOps, Travis CI, AppVeyor and CircleCI.
Stars: ✭ 161 (-10.56%)
Mutual labels:  appveyor, ci, circleci, travis, gitlab
Tox
Command line driven CI frontend and development task automation tool.
Stars: ✭ 2,523 (+1301.67%)
Mutual labels:  appveyor, continuous-integration, circleci, travis, gitlab
Skyhook
Parses webhooks and forwards them in the proper format to Discord.
Stars: ✭ 263 (+46.11%)
Mutual labels:  appveyor, jenkins, circleci, gitlab, bitbucket
Danger
🚫 Stop saying "you forgot to …" in code review (in Ruby)
Stars: ✭ 4,691 (+2506.11%)
Mutual labels:  ci, travis, gitlab, bitbucket
Nevergreen
🐤 A build monitor with attitude
Stars: ✭ 170 (-5.56%)
Mutual labels:  ci, continuous-integration, jenkins, circleci
playwright-ci
☁️ Set up Playwright in CI
Stars: ✭ 27 (-85%)
Mutual labels:  jenkins, circleci, gitlab, bitbucket
Gitlab Ci Pipeline Php
☕️ Docker images for test PHP applications with Gitlab CI (or any other CI platform!)
Stars: ✭ 451 (+150.56%)
Mutual labels:  ci, continuous-integration, gitlab
Bzppx Codepub
暴走皮皮虾之代码发布系统,是现代的持续集成发布系统,由后台管理系统和agent两部分组成,一个运行着的agent就是一个节点,本系统并不是造轮子,是"鸟枪"到"大炮"的创新,对"前朝遗老"的革命.
Stars: ✭ 471 (+161.67%)
Mutual labels:  ci, continuous-integration, jenkins
Industrial ci
Easy continuous integration repository for ROS repositories
Stars: ✭ 146 (-18.89%)
Mutual labels:  continuous-integration, travis, gitlab
Reviewdog
🐶 Automated code review tool integrated with any code analysis tools regardless of programming language
Stars: ✭ 4,541 (+2422.78%)
Mutual labels:  ci, gitlab, bitbucket
Cibuildwheel
🎡 Build Python wheels for all the platforms on CI with minimal configuration.
Stars: ✭ 620 (+244.44%)
Mutual labels:  appveyor, ci, circleci
Ansible Role Jenkins
Ansible Role - Jenkins CI
Stars: ✭ 689 (+282.78%)
Mutual labels:  ci, continuous-integration, jenkins
Danger Js
⚠️ Stop saying "you forgot to …" in code review
Stars: ✭ 4,076 (+2164.44%)
Mutual labels:  ci, jenkins, travis
Threatmapper
Identify vulnerabilities in running containers, images, hosts and repositories
Stars: ✭ 361 (+100.56%)
Mutual labels:  jenkins, circleci, gitlab
Ccmenu
CCMenu is a Mac application to monitor continuous integration servers.
Stars: ✭ 306 (+70%)
Mutual labels:  ci, continuous-integration, jenkins
Android Ci
A docker image for building Android apps. Supports multiple SDK Build Tools.
Stars: ✭ 101 (-43.89%)
Mutual labels:  ci, gitlab, bitbucket
Cimonitor
Displays CI statuses on a dashboard and triggers fun modules representing the status!
Stars: ✭ 34 (-81.11%)
Mutual labels:  ci, continuous-integration, gitlab
Terraform Multienv
A template for maintaining a multiple environments infrastructure with Terraform. This template includes a CI/CD process, that applies the infrastructure in an AWS account.
Stars: ✭ 107 (-40.56%)
Mutual labels:  drone, ci, circleci
CI-Utils
Utilities for running Common Lisp on CI platforms
Stars: ✭ 18 (-90%)
Mutual labels:  circleci, ci, appveyor

env-ci

Get environment variables exposed by CI services.

Travis Codecov Greenkeeper badge

Adapted from codecov-node.

Install

$ npm install --save env-ci

Usage

const envCi = require('env-ci');

const {name, service, isCi, branch, commit, tag, build, buildUrl, job, jobUrl, isPr, pr, prBranch, slug, root} = envCi();

if (isCI) {
  console.log(`Building repo ${slug} on ${name} service`);

  if (isPr) {
    console.log(`Building Pull Request #${pr} originating from branch ${prBranch} and targeting branch ${branch}`);
  } else {
    console.log(`Building branch ${branch}`);
  }

  if (service === 'travis') {
    // Do something specific to Travis CI
  }
}

Supported variables

Variable Description
name CI service Commercial name (e.g. Travis CI, CircleCI, GitLab CI/CD)
service Standardized CI service name (e.g. travis, circleci, gitlab)
isCi true is running on a CI, false otherwise
branch Git branch being built or targeted by a Pull Request
commit Commit sha that triggered the CI build
tag Git tag that triggered the CI build
build CI service build number
buildUrl Link to the CI service build
job CI service job number
jobUrl Link to the CI service job
isPr true if the build has been triggered by a Pull Request, false otherwise
pr Pull Request number (only for builds triggered by a Pull Request)
prBranch Git branch branch from which the Pull Request originated (only for builds triggered by a Pull Request)
slug The slug (in form: owner_name/repo_name) of the repository currently being built
root The path to the directory where the repository is being built

Note: Some variables can be detected only on certain CI services. See Supported CI.

Note: The pr and prBranch properties are only available for builds triggered when a Pull Request is opened/updated and not on builds triggered by a push on a branch even if that branch happens to be the branch from which the Pull Request originated.

Supported CI

CI Service (name) service isCi branch commit tag build buildUrl job jobUrl isPr pr prBranch slug root
AppVeyor appveyor
Bamboo bamboo
Bitbucket bitbucket
Bitrise bitrise
Buddy buddy ⚠️
Buildkite buildkite
CircleCI circleci ⚠️
Cirrus CI cirrus
AWS CodeBuild codebuild ⚠️
Codefresh codefresh
Codeship codeship
Drone drone
GitHub Actions github
GitLab CI/CD gitlab
Jenkins jenkins ⚠️ ⚠️ ⚠️ ⚠️
Puppet puppet
Sail CI sail ⚠️
Scrutinizer scrutinizer
Semaphore semaphore ⚠️ ⚠️
Shippable shippable
TeamCity teamcity
Travis CI travis
Visual Studio Team Services vsts
Wercker wercker

⚠️ See Caveats

Note: Unsupported properties will always be undefined. For example if a Ci services doesn't support triggering builds when a Pull Request is opened/updated, isPr will be undefined.

Note: If none of the above CI services is detected, commit and branch are determined based on the local Git repository, and isCi is determined based on the CI environment variable.

API

envCi(options) => Result

options

Type: Object

env

Type: Object
Default: process.env

The object to read environment variables from.

cwd

Type: String
Default: process.cwd()

The current working directory in which to execute git commands used to determine the commit and branch Result properties in case no supported CI is detected.

Result

Type: Object

Environment variables values exposed by the CI service.

Caveats

AWS CodeBuild

AWS CodeBuild doesn't provide an environment variable to determine the current Git branch being built. In addition, it clones the repository in a detached head state so the branch cannot be determined with git rev-parse --abbrev-ref HEAD. To work around this limitation, env-ci look for the remote branches having the same HEAD as the local detached HEAD to determine the branch from which the detached HEAD was created. In the rare case where there is multiple remote branches with the same HEAD as the local detached HEAD, env-ci will arbitrarily pick the first one. This can lead to an inaccurate branch value in such circumstances.

Buddy

For builds triggered when a Pull Request is opened/updated, Buddy doesn't provide an environment variable indicating the branch from which the Pull Request originated nor the target branch. It also build from a branch named pull/<PR number> so the target branch cannot be determined with a git command. Therefore in the case of Pull Request builds, env-ci will not be able to determine the branch and prBranch properties.

See feature request.

CircleCI

For builds triggered when a Pull Request is opened/updated, CircleCI doesn't provide an environment variable indicating the target branch. Therefore in the case of Pull Request builds, env-ci will not be able to determine the branch property. However prBranch will be set.

See feature request.

Jenkins

Triggering build when a Pull Request is opened/updated is supported only via the ghprb-plugin and gitlab-plugin. Therefore env-ci will set isPr, pr and prBranch and define branch with the Pull Request target branch only if one those plugin is used.

Sail

For builds triggered when a Pull Request is opened/updated, Sail doesn't provide an environment variable indicating the target branch, and the one for the current branch is set to pull/<PR number> independently of the the branch name from which the Pull Request originated. Therefore in the case of Pull Request builds, env-ci will not be able to determine the branch and prBranch properties.

Semaphore

For builds triggered when a Pull Request is opened/updated, Semaphore 1.0 doesn't provide an environment variable indicating the target branch. Therefore in the case of Pull Request builds, env-ci will not be able to determine the branch property. However prBranch will be set. On Semaphore 2.0 the branch and prBranch properties will work as expected.

The property tag is only available on Semaphore 2.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].