semantic-release/env-ci là một trong những repo tập trung tự động hoá mà TopGit theo dõi, hiện có 243 sao, viết chủ yếu bằng JavaScript. Get environment variables exposed by CI services
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
import envCi from "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
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
Azure Pipelines
azure-devops
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:white_check_mark:
:x:
:x:
:x:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:white_check_mark:
Bamboo
bamboo
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:x:
:x:
:x:
:x:
:white_check_mark:
Bitbucket
bitbucket
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:x:
:x:
:x:
:x:
:white_check_mark:
:white_check_mark:
Bitrise
bitrise
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:x:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
Buddy
buddy
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:x:
:white_check_mark:
:white_check_mark:
:x:
:white_check_mark:
:x:
Buildkite
buildkite
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:x:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
CircleCI
circleci
:white_check_mark:
:warning:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
Cirrus CI
cirrus
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
Cloudflare Pages
cloudflarePages
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:x:
:x:
:x:
:x:
:x:
:x:
:x:
:x:
:white_check_mark:
AWS CodeBuild
codebuild
:white_check_mark:
:warning:
:white_check_mark:
:x:
:white_check_mark:
:white_check_mark:
:x:
:x:
:x:
:x:
:x:
:x:
:white_check_mark:
Codefresh
codefresh
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:white_check_mark:
:white_check_mark:
:x:
:x:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
Codeship
codeship
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:x:
:x:
:x:
:x:
:white_check_mark:
:x:
Drone
drone
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
GitHub Actions
github
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:white_check_mark:
:white_check_mark:
:x:
:x:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
GitLab CI/CD
gitlab
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
Jenkins
jenkins
:white_check_mark:
:warning:
:white_check_mark:
:x:
:white_check_mark:
:white_check_mark:
:x:
:x:
:warning:
:warning:
:warning:
:white_check_mark:
:white_check_mark:
Netlify
netlify
:white_check_mark:
:warning:
:white_check_mark:
:x:
:white_check_mark:
:white_check_mark:
:x:
:x:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
Puppet
puppet
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:white_check_mark:
:white_check_mark:
:x:
:x:
:x:
:x:
:x:
:x:
:white_check_mark:
Sail CI
sail
:white_check_mark:
:warning:
:white_check_mark:
:x:
:x:
:x:
:x:
:x:
:white_check_mark:
:white_check_mark:
:x:
:white_check_mark:
:white_check_mark:
Screwdriver.cd
screwdriver
:white_check_mark:
:warning:
:white_check_mark:
:x:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
Scrutinizer
scrutinizer
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:white_check_mark:
:x:
:x:
:x:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:x:
Semaphore
semaphore
:white_check_mark:
:warning:
:white_check_mark:
:warning:
:white_check_mark:
:x:
:x:
:x:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
Shippable
shippable
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
TeamCity
teamcity
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:white_check_mark:
:x:
:x:
:x:
:x:
:x:
:x:
:white_check_mark:
:white_check_mark:
Travis CI
travis
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
Vela
vela
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:x:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
Vercel
vercel
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:x:
:x:
:x:
:x:
:x:
:x:
:x:
:white_check_mark:
:x:
Wercker
wercker
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:white_check_mark:
:white_check_mark:
:x:
:x:
:x:
:x:
:x:
:white_check_mark:
:white_check_mark:
JetBrains Space
jetbrainsSpace
:white_check_mark:
:white_check_mark:
:white_check_mark:
:x:
:white_check_mark:
:x:
:x:
:x:
:x:
:x:
:x:
:white_check_mark:
:x:
Woodpecker CI
woodpecker
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:white_check_mark:
:warning: 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.
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.
Cloudflare Pages
For builds triggered when a Pull Request is opened/updated, Cloudflare Pages will re-use the branch variable for the
originating branch and not provide a target. Therefore env-ci will not be able to determine the prBranch property
however branch will always be set.
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.
Netlify
For builds triggered when a Pull Request is opened/updated, Netlify 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
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.
Screwdriver
For builds triggered when a Pull Request is opened/updated, Screwdriver sets the env.GIT_BRANCH as head:pr branch
type (Example:origin/refs/pull/1/head:pr) while at commit level (non PR) it does set it with the actual branch (Example: origin/main).
semantic-release/env-ci thuộc nhóm Automation trên TopGit, cùng 20 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về semantic-release/env-ci ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/semantic-release/env-ci là nguồn chính thức.
semantic-release/env-ci có bao nhiêu sao?
semantic-release/env-ci có 243 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/semantic-release/env-ci. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
semantic-release/env-ci còn đang phát triển không?
Commit gần nhất trên semantic-release/env-ci là 7 ngày trước (theo timestamp GitHub). Repo có 47 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
semantic-release/env-ci viết bằng ngôn ngữ gì?
semantic-release/env-ci chủ yếu viết bằng JavaScript. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Vì sao semantic-release/env-ci được xếp vào nhóm Automation?
TopGit xếp semantic-release/env-ci vào nhóm Automation dựa trên GitHub topics và mô tả của repo (gắn thẻ: "appveyor", "bamboo", "bitbucket"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về env-ci?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về env-ci.