Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

env-ci

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

env-ci - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

9

index.js
'use strict';
const process = require('process');
const git = require('./lib/git');

@@ -27,9 +28,9 @@

module.exports = () => {
module.exports = ({env = process.env, cwd = process.cwd()} = {}) => {
for (const name of Object.keys(services)) {
if (services[name].detect()) {
return Object.assign({isCi: true}, services[name].configuration());
if (services[name].detect({env, cwd})) {
return Object.assign({isCi: true}, services[name].configuration({env, cwd}));
}
}
return Object.assign({isCi: Boolean(process.env.CI)}, git.configuration());
return Object.assign({isCi: Boolean(env.CI)}, git.configuration({env, cwd}));
};
// https://www.appveyor.com/docs/environment-variables
module.exports = {
detect() {
return Boolean(process.env.APPVEYOR);
detect({env}) {
return Boolean(env.APPVEYOR);
},
configuration() {
configuration({env}) {
return {
name: 'Appveyor',
service: 'appveyor',
commit: process.env.APPVEYOR_REPO_COMMIT,
build: process.env.APPVEYOR_BUILD_NUMBER,
buildUrl: `https://ci.appveyor.com/project/${process.env.APPVEYOR_PROJECT_SLUG}/build/${
process.env.APPVEYOR_BUILD_VERSION
}`,
branch: process.env.APPVEYOR_REPO_BRANCH,
job: process.env.APPVEYOR_JOB_NUMBER,
jobUrl: `https://ci.appveyor.com/project/${process.env.APPVEYOR_PROJECT_SLUG}/build/job/${
process.env.APPVEYOR_JOB_ID
}`,
pr: process.env.APPVEYOR_PULL_REQUEST_NUMBER,
isPr: Boolean(process.env.APPVEYOR_PULL_REQUEST_NUMBER),
slug: process.env.APPVEYOR_REPO_NAME,
root: process.env.APPVEYOR_BUILD_FOLDER,
commit: env.APPVEYOR_REPO_COMMIT,
build: env.APPVEYOR_BUILD_NUMBER,
buildUrl: `https://ci.appveyor.com/project/${env.APPVEYOR_PROJECT_SLUG}/build/${env.APPVEYOR_BUILD_VERSION}`,
branch: env.APPVEYOR_REPO_BRANCH,
job: env.APPVEYOR_JOB_NUMBER,
jobUrl: `https://ci.appveyor.com/project/${env.APPVEYOR_PROJECT_SLUG}/build/job/${env.APPVEYOR_JOB_ID}`,
pr: env.APPVEYOR_PULL_REQUEST_NUMBER,
isPr: Boolean(env.APPVEYOR_PULL_REQUEST_NUMBER),
slug: env.APPVEYOR_REPO_NAME,
root: env.APPVEYOR_BUILD_FOLDER,
};
},
};

@@ -6,17 +6,17 @@ // https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html

module.exports = {
detect() {
return Boolean(process.env.bamboo_agentId);
detect({env}) {
return Boolean(env.bamboo_agentId);
},
configuration() {
configuration({env}) {
return {
name: 'Bamboo',
service: 'bamboo',
commit: process.env.bamboo_planRepository_1_revision,
build: process.env.bamboo_buildNumber,
buildUrl: process.env.bamboo_buildResultsUrl,
branch: process.env.bamboo_planRepository_1_branchName,
job: process.env.bamboo_buildKey,
root: process.env.bamboo_build_working_directory,
commit: env.bamboo_planRepository_1_revision,
build: env.bamboo_buildNumber,
buildUrl: env.bamboo_buildResultsUrl,
branch: env.bamboo_planRepository_1_branchName,
job: env.bamboo_buildKey,
root: env.bamboo_build_working_directory,
};
},
};
// https://confluence.atlassian.com/bitbucket/environment-variables-794502608.html
module.exports = {
detect() {
return Boolean(process.env.BITBUCKET_BUILD_NUMBER);
detect({env}) {
return Boolean(env.BITBUCKET_BUILD_NUMBER);
},
configuration() {
configuration({env}) {
return {
name: 'Bitbucket Pipelines',
service: 'bitbucket',
commit: process.env.BITBUCKET_COMMIT,
build: process.env.BITBUCKET_BUILD_NUMBER,
buildUrl: `https://bitbucket.org/${process.env.BITBUCKET_REPO_SLUG}/addon/pipelines/home#!/results/${
process.env.BITBUCKET_BUILD_NUMBER
commit: env.BITBUCKET_COMMIT,
build: env.BITBUCKET_BUILD_NUMBER,
buildUrl: `https://bitbucket.org/${env.BITBUCKET_REPO_SLUG}/addon/pipelines/home#!/results/${
env.BITBUCKET_BUILD_NUMBER
}`,
branch: process.env.BITBUCKET_BRANCH,
slug: process.env.BITBUCKET_REPO_SLUG,
root: process.env.BITBUCKET_CLONE_DIR,
branch: env.BITBUCKET_BRANCH,
slug: env.BITBUCKET_REPO_SLUG,
root: env.BITBUCKET_CLONE_DIR,
};
},
};
// http://devcenter.bitrise.io/faq/available-environment-variables
module.exports = {
detect() {
return Boolean(process.env.BITRISE_IO);
detect({env}) {
return Boolean(env.BITRISE_IO);
},
configuration() {
configuration({env}) {
return {
name: 'Bitrise',
service: 'bitrise',
commit: process.env.BITRISE_GIT_COMMIT,
build: process.env.BITRISE_BUILD_NUMBER,
buildUrl: process.env.BITRISE_BUILD_URL,
branch: process.env.BITRISE_GIT_BRANCH,
pr: process.env.BITRISE_PULL_REQUEST === 'false' ? undefined : process.env.BITRISE_PULL_REQUEST,
isPr: Boolean(process.env.BITRISE_PULL_REQUEST && process.env.BITRISE_PULL_REQUEST !== 'false'),
slug: process.env.BITRISE_APP_SLUG,
commit: env.BITRISE_GIT_COMMIT,
build: env.BITRISE_BUILD_NUMBER,
buildUrl: env.BITRISE_BUILD_URL,
branch: env.BITRISE_GIT_BRANCH,
pr: env.BITRISE_PULL_REQUEST === 'false' ? undefined : env.BITRISE_PULL_REQUEST,
isPr: Boolean(env.BITRISE_PULL_REQUEST && env.BITRISE_PULL_REQUEST !== 'false'),
slug: env.BITRISE_APP_SLUG,
};
},
};
// https://buddy.works/knowledge/deployments/how-use-environment-variables#default-environment-variables
module.exports = {
detect() {
return Boolean(process.env.BUDDY_WORKSPACE_ID);
detect({env}) {
return Boolean(env.BUDDY_WORKSPACE_ID);
},
configuration() {
configuration({env}) {
return {
name: 'Buddy',
service: 'buddy',
commit: process.env.BUDDY_EXECUTION_REVISION,
build: process.env.BUDDY_EXECUTION_ID,
buildUrl: process.env.BUDDY_EXECUTION_URL,
branch: process.env.BUDDY_EXECUTION_BRANCH,
pr: process.env.BUDDY_EXECUTION_PULL_REQUEST_ID,
isPr: Boolean(
process.env.BUDDY_EXECUTION_PULL_REQUEST_ID && process.env.BUDDY_EXECUTION_PULL_REQUEST_ID !== 'false'
),
slug: process.env.BUDDY_REPO_SLUG,
commit: env.BUDDY_EXECUTION_REVISION,
build: env.BUDDY_EXECUTION_ID,
buildUrl: env.BUDDY_EXECUTION_URL,
branch: env.BUDDY_EXECUTION_BRANCH,
pr: env.BUDDY_EXECUTION_PULL_REQUEST_ID,
isPr: Boolean(env.BUDDY_EXECUTION_PULL_REQUEST_ID && env.BUDDY_EXECUTION_PULL_REQUEST_ID !== 'false'),
slug: env.BUDDY_REPO_SLUG,
};
},
};
// https://buildkite.com/docs/builds/environment-variables
module.exports = {
detect() {
return Boolean(process.env.BUILDKITE);
detect({env}) {
return Boolean(env.BUILDKITE);
},
configuration() {
configuration({env}) {
return {
name: 'Buildkite',
service: 'buildkite',
build: process.env.BUILDKITE_BUILD_NUMBER,
buildUrl: process.env.BUILDKITE_BUILD_URL,
commit: process.env.BUILDKITE_COMMIT,
branch: process.env.BUILDKITE_BRANCH,
slug: `${process.env.BUILDKITE_ORGANIZATION_SLUG}/${process.env.BUILDKITE_PROJECT_SLUG}`,
pr: process.env.BUILDKITE_PULL_REQUEST === 'false' ? undefined : process.env.BUILDKITE_PULL_REQUEST,
isPr: Boolean(process.env.BUILDKITE_PULL_REQUEST && process.env.BUILDKITE_PULL_REQUEST !== 'false'),
root: process.env.BUILDKITE_BUILD_CHECKOUT_PATH,
build: env.BUILDKITE_BUILD_NUMBER,
buildUrl: env.BUILDKITE_BUILD_URL,
commit: env.BUILDKITE_COMMIT,
branch: env.BUILDKITE_BRANCH,
slug: `${env.BUILDKITE_ORGANIZATION_SLUG}/${env.BUILDKITE_PROJECT_SLUG}`,
pr: env.BUILDKITE_PULL_REQUEST === 'false' ? undefined : env.BUILDKITE_PULL_REQUEST,
isPr: Boolean(env.BUILDKITE_PULL_REQUEST && env.BUILDKITE_PULL_REQUEST !== 'false'),
root: env.BUILDKITE_BUILD_CHECKOUT_PATH,
};
},
};

@@ -5,22 +5,22 @@ // Circle 1.0 docs: https://circleci.com/docs/1.0/environment-variables

module.exports = {
detect() {
return Boolean(process.env.CIRCLECI);
detect({env}) {
return Boolean(env.CIRCLECI);
},
configuration() {
configuration({env}) {
// Support both 1.0 and 2.0
const pullRequestUrl = process.env.CIRCLE_PULL_REQUEST || process.env.CI_PULL_REQUEST;
const pullRequest = pullRequestUrl ? pullRequestUrl.split('/').pop() : process.env.CIRCLE_PR_NUMBER;
const pullRequestUrl = env.CIRCLE_PULL_REQUEST || env.CI_PULL_REQUEST;
const pullRequest = pullRequestUrl ? pullRequestUrl.split('/').pop() : env.CIRCLE_PR_NUMBER;
return {
name: 'CircleCI',
service: 'circleci',
build: process.env.CIRCLE_BUILD_NUM,
buildUrl: process.env.CIRCLE_BUILD_URL,
job: `${process.env.CIRCLE_BUILD_NUM}.${process.env.CIRCLE_NODE_INDEX}`,
commit: process.env.CIRCLE_SHA1,
branch: process.env.CIRCLE_BRANCH,
build: env.CIRCLE_BUILD_NUM,
buildUrl: env.CIRCLE_BUILD_URL,
job: `${env.CIRCLE_BUILD_NUM}.${env.CIRCLE_NODE_INDEX}`,
commit: env.CIRCLE_SHA1,
branch: env.CIRCLE_BRANCH,
pr: pullRequest,
isPr: Boolean(pullRequest),
slug: `${process.env.CIRCLE_PROJECT_USERNAME}/${process.env.CIRCLE_PROJECT_REPONAME}`,
slug: `${env.CIRCLE_PROJECT_USERNAME}/${env.CIRCLE_PROJECT_REPONAME}`,
};
},
};

@@ -6,21 +6,21 @@ // https://cirrus-ci.org/guide/writing-tasks/#environment-variables

module.exports = {
detect() {
return Boolean(process.env.CIRRUS_CI);
detect({env}) {
return Boolean(env.CIRRUS_CI);
},
configuration() {
configuration({env}) {
return {
name: 'Cirrus CI',
service: 'cirrus',
commit: process.env.CIRRUS_CHANGE_IN_REPO,
build: process.env.CIRRUS_BUILD_ID,
buildUrl: `${CIRRUS_CI_DASHBOARD}/build/${process.env.CIRRUS_BUILD_ID}`,
job: process.env.CIRRUS_TASK_ID,
jobUrl: `${CIRRUS_CI_DASHBOARD}/task/${process.env.CIRRUS_TASK_ID}`,
branch: process.env.CIRRUS_BRANCH,
pr: process.env.CIRRUS_PR,
isPr: Boolean(process.env.CIRRUS_PR && process.env.CIRRUS_PR !== 'false'),
slug: process.env.CIRRUS_REPO_FULL_NAME,
root: process.env.CIRRUS_WORKING_DIR,
commit: env.CIRRUS_CHANGE_IN_REPO,
build: env.CIRRUS_BUILD_ID,
buildUrl: `${CIRRUS_CI_DASHBOARD}/build/${env.CIRRUS_BUILD_ID}`,
job: env.CIRRUS_TASK_ID,
jobUrl: `${CIRRUS_CI_DASHBOARD}/task/${env.CIRRUS_TASK_ID}`,
branch: env.CIRRUS_BRANCH,
pr: env.CIRRUS_PR,
isPr: Boolean(env.CIRRUS_PR && env.CIRRUS_PR !== 'false'),
slug: env.CIRRUS_REPO_FULL_NAME,
root: env.CIRRUS_WORKING_DIR,
};
},
};

@@ -1,2 +0,2 @@

const git = require('./git');
const {head, branch} = require('./git');

@@ -6,18 +6,18 @@ // https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html

module.exports = {
detect() {
return Boolean(process.env.CODEBUILD_BUILD_ID);
detect({env}) {
return Boolean(env.CODEBUILD_BUILD_ID);
},
configuration() {
configuration({env, cwd}) {
return {
name: 'AWS CodeBuild',
service: 'codebuild',
commit: git.head(),
build: process.env.CODEBUILD_BUILD_ID,
branch: git.branch(),
buildUrl: `https://console.aws.amazon.com/codebuild/home?region=${process.env.AWS_REGION}#/builds/${
process.env.CODEBUILD_BUILD_ID
commit: head({env, cwd}),
build: env.CODEBUILD_BUILD_ID,
branch: branch({env, cwd}),
buildUrl: `https://console.aws.amazon.com/codebuild/home?region=${env.AWS_REGION}#/builds/${
env.CODEBUILD_BUILD_ID
}/view/new`,
root: process.env.PWD,
root: env.PWD,
};
},
};
// https://documentation.codeship.com/basic/builds-and-configuration/set-environment-variables
module.exports = {
detect() {
return process.env.CI_NAME && process.env.CI_NAME === 'codeship';
detect({env}) {
return env.CI_NAME && env.CI_NAME === 'codeship';
},
configuration() {
configuration({env}) {
return {
name: 'Codeship',
service: 'codeship',
build: process.env.CI_BUILD_NUMBER,
buildUrl: process.env.CI_BUILD_URL,
commit: process.env.CI_COMMIT_ID,
branch: process.env.CI_BRANCH,
slug: process.env.CI_REPO_NAME,
build: env.CI_BUILD_NUMBER,
buildUrl: env.CI_BUILD_URL,
commit: env.CI_COMMIT_ID,
branch: env.CI_BRANCH,
slug: env.CI_REPO_NAME,
};
},
};
// http://readme.drone.io/0.5/usage/environment-reference
module.exports = {
detect() {
return Boolean(process.env.DRONE);
detect({env}) {
return Boolean(env.DRONE);
},
configuration() {
configuration({env}) {
return {
name: 'Drone',
service: 'drone',
commit: process.env.DRONE_COMMIT_SHA,
build: process.env.DRONE_BUILD_NUMBER,
branch: process.env.DRONE_BRANCH,
job: process.env.DRONE_JOB_NUMBER,
pr: process.env.DRONE_PULL_REQUEST,
isPr: process.env.DRONE_BUILD_EVENT === 'pull_request',
slug: `${process.env.DRONE_REPO_OWNER}/${process.env.DRONE_REPO_NAME}`,
commit: env.DRONE_COMMIT_SHA,
build: env.DRONE_BUILD_NUMBER,
branch: env.DRONE_BRANCH,
job: env.DRONE_JOB_NUMBER,
pr: env.DRONE_PULL_REQUEST,
isPr: env.DRONE_BUILD_EVENT === 'pull_request',
slug: `${env.DRONE_REPO_OWNER}/${env.DRONE_REPO_NAME}`,
};
},
};
const execa = require('execa');
function configuration() {
function configuration(options) {
return {
commit: head(),
branch: branch(),
commit: head(options),
branch: branch(options),
};
}
function head() {
function head(options) {
try {
return execa.sync('git', ['rev-parse', 'HEAD']).stdout;
return execa.sync('git', ['rev-parse', 'HEAD'], options).stdout;
} catch (error) {

@@ -18,9 +18,9 @@ return undefined;

function branch() {
function branch(options) {
try {
const headRef = execa.sync('git', ['rev-parse', '--abbrev-ref', 'HEAD']).stdout;
const headRef = execa.sync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], options).stdout;
if (headRef === 'HEAD') {
const branch = execa
.sync('git', ['show', '-s', '--pretty=%d', 'HEAD'])
.sync('git', ['show', '-s', '--pretty=%d', 'HEAD'], options)
.stdout.replace(/^\(|\)$/g, '')

@@ -27,0 +27,0 @@ .split(', ')

// https://docs.gitlab.com/ce/ci/variables/README.html
module.exports = {
detect() {
return Boolean(process.env.GITLAB_CI);
detect({env}) {
return Boolean(env.GITLAB_CI);
},
configuration() {
configuration({env}) {
return {
name: 'GitLab CI/CD',
service: 'gitlab',
commit: process.env.CI_COMMIT_SHA,
build: process.env.CI_PIPELINE_ID,
buildUrl: `${process.env.CI_PROJECT_URL}/pipelines/${process.env.CI_PIPELINE_ID}`,
job: process.env.CI_JOB_ID,
jobUrl: `${process.env.CI_PROJECT_URL}/-/jobs/${process.env.CI_JOB_ID}`,
branch: process.env.CI_COMMIT_REF_NAME,
slug: process.env.CI_PROJECT_PATH,
root: process.env.CI_PROJECT_DIR,
commit: env.CI_COMMIT_SHA,
build: env.CI_PIPELINE_ID,
buildUrl: `${env.CI_PROJECT_URL}/pipelines/${env.CI_PIPELINE_ID}`,
job: env.CI_JOB_ID,
jobUrl: `${env.CI_PROJECT_URL}/-/jobs/${env.CI_JOB_ID}`,
branch: env.CI_COMMIT_REF_NAME,
slug: env.CI_PROJECT_PATH,
root: env.CI_PROJECT_DIR,
};
},
};

@@ -1,2 +0,2 @@

const git = require('./git');
const {head} = require('./git');

@@ -6,22 +6,18 @@ // https://wiki.jenkins.io/display/JENKINS/Building+a+software+project

module.exports = {
detect() {
return Boolean(process.env.JENKINS_URL);
detect({env}) {
return Boolean(env.JENKINS_URL);
},
configuration() {
configuration({env, cwd}) {
return {
name: 'Jenkins',
service: 'jenkins',
commit: process.env.ghprbActualCommit || process.env.GIT_COMMIT || git.head(),
branch:
process.env.ghprbSourceBranch ||
process.env.GIT_LOCAL_BRANCH ||
process.env.GIT_BRANCH ||
process.env.BRANCH_NAME,
build: process.env.BUILD_NUMBER,
buildUrl: process.env.BUILD_URL,
root: process.env.WORKSPACE,
pr: process.env.ghprbPullId || process.env.CHANGE_ID,
isPr: Boolean(process.env.ghprbPullId || process.env.CHANGE_ID),
commit: env.ghprbActualCommit || env.GIT_COMMIT || head({env, cwd}),
branch: env.ghprbSourceBranch || env.GIT_LOCAL_BRANCH || env.GIT_BRANCH || env.BRANCH_NAME,
build: env.BUILD_NUMBER,
buildUrl: env.BUILD_URL,
root: env.WORKSPACE,
pr: env.ghprbPullId || env.CHANGE_ID,
isPr: Boolean(env.ghprbPullId || env.CHANGE_ID),
};
},
};

@@ -1,2 +0,2 @@

const git = require('./git');
const {head} = require('./git');

@@ -6,18 +6,18 @@ // https://semaphoreci.com/docs/available-environment-variables.html

module.exports = {
detect() {
return Boolean(process.env.SEMAPHORE);
detect({env}) {
return Boolean(env.SEMAPHORE);
},
configuration() {
configuration({env, cwd}) {
return {
name: 'Semaphore',
service: 'semaphore',
commit: git.head(),
build: process.env.SEMAPHORE_BUILD_NUMBER,
branch: process.env.BRANCH_NAME,
pr: process.env.PULL_REQUEST_NUMBER,
isPr: Boolean(process.env.PULL_REQUEST_NUMBER && process.env.PULL_REQUEST_NUMBER !== 'false'),
slug: process.env.SEMAPHORE_REPO_SLUG,
root: process.env.SEMAPHORE_PROJECT_DIR,
commit: head({env, cwd}),
build: env.SEMAPHORE_BUILD_NUMBER,
branch: env.BRANCH_NAME,
pr: env.PULL_REQUEST_NUMBER,
isPr: Boolean(env.PULL_REQUEST_NUMBER && env.PULL_REQUEST_NUMBER !== 'false'),
slug: env.SEMAPHORE_REPO_SLUG,
root: env.SEMAPHORE_PROJECT_DIR,
};
},
};
// http://docs.shippable.com/ci/env-vars/#stdEnv
module.exports = {
detect() {
return Boolean(process.env.SHIPPABLE);
detect({env}) {
return Boolean(env.SHIPPABLE);
},
configuration() {
configuration({env}) {
return {
name: 'Shippable',
service: 'shippable',
commit: process.env.COMMIT,
build: process.env.BUILD_NUMBER,
buildUrl: process.env.BUILD_URL,
branch: process.env.BASE_BRANCH || process.env.BRANCH,
job: process.env.JOB_NUMBER,
pr: process.env.PULL_REQUEST === 'false' ? undefined : process.env.PULL_REQUEST,
isPr: Boolean(process.env.IS_PULL_REQUEST && process.env.IS_PULL_REQUEST === 'true'),
slug: process.env.SHIPPABLE_REPO_SLUG,
root: process.env.SHIPPABLE_BUILD_DIR,
commit: env.COMMIT,
build: env.BUILD_NUMBER,
buildUrl: env.BUILD_URL,
branch: env.BASE_BRANCH || env.BRANCH,
job: env.JOB_NUMBER,
pr: env.PULL_REQUEST === 'false' ? undefined : env.PULL_REQUEST,
isPr: Boolean(env.IS_PULL_REQUEST && env.IS_PULL_REQUEST === 'true'),
slug: env.SHIPPABLE_REPO_SLUG,
root: env.SHIPPABLE_BUILD_DIR,
};
},
};

@@ -18,6 +18,6 @@ // https://confluence.jetbrains.com/display/TCD10/Predefined+Build+Parameters

module.exports = {
detect() {
return Boolean(process.env.TEAMCITY_VERSION);
detect({env}) {
return Boolean(env.TEAMCITY_VERSION);
},
configuration() {
configuration({env}) {
return Object.assign(

@@ -27,9 +27,9 @@ {

service: 'teamcity',
commit: process.env.BUILD_VCS_NUMBER,
build: process.env.BUILD_NUMBER,
slug: process.env.TEAMCITY_BUILDCONF_NAME,
commit: env.BUILD_VCS_NUMBER,
build: env.BUILD_NUMBER,
slug: env.TEAMCITY_BUILDCONF_NAME,
},
getProperties(process.env)
getProperties(env)
);
},
};
// https://docs.travis-ci.com/user/environment-variables
module.exports = {
detect() {
return Boolean(process.env.TRAVIS);
detect({env}) {
return Boolean(env.TRAVIS);
},
configuration() {
configuration({env}) {
return {
name: 'Travis CI',
service: 'travis',
commit: process.env.TRAVIS_COMMIT,
build: process.env.TRAVIS_BUILD_NUMBER,
branch: process.env.TRAVIS_BRANCH,
job: process.env.TRAVIS_JOB_NUMBER,
pr: process.env.TRAVIS_PULL_REQUEST === 'false' ? undefined : process.env.TRAVIS_PULL_REQUEST,
isPr: Boolean(process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false'),
slug: process.env.TRAVIS_REPO_SLUG,
root: process.env.TRAVIS_BUILD_DIR,
commit: env.TRAVIS_COMMIT,
build: env.TRAVIS_BUILD_NUMBER,
branch: env.TRAVIS_BRANCH,
job: env.TRAVIS_JOB_NUMBER,
pr: env.TRAVIS_PULL_REQUEST === 'false' ? undefined : env.TRAVIS_PULL_REQUEST,
isPr: Boolean(env.TRAVIS_PULL_REQUEST && env.TRAVIS_PULL_REQUEST !== 'false'),
slug: env.TRAVIS_REPO_SLUG,
root: env.TRAVIS_BUILD_DIR,
};
},
};
// https://docs.microsoft.com/en-us/vsts/pipelines/build/variables
module.exports = {
detect() {
return Boolean(process.env.BUILD_BUILDURI);
detect({env}) {
return Boolean(env.BUILD_BUILDURI);
},
configuration() {
configuration({env}) {
return {
name: 'Visual Studio Team Services',
service: 'vsts',
commit: process.env.BUILD_SOURCEVERSION,
build: process.env.BUILD_BUILDNUMBER,
branch: process.env.BUILD_SOURCEBRANCHNAME,
pr: process.env.SYSTEM_PULLREQUEST_PULLREQUESTID,
isPr: Boolean(
process.env.SYSTEM_PULLREQUEST_PULLREQUESTID && process.env.SYSTEM_PULLREQUEST_PULLREQUESTID !== 'false'
),
root: process.env.BUILD_REPOSITORY_LOCALPATH,
commit: env.BUILD_SOURCEVERSION,
build: env.BUILD_BUILDNUMBER,
branch: env.BUILD_SOURCEBRANCHNAME,
pr: env.SYSTEM_PULLREQUEST_PULLREQUESTID,
isPr: Boolean(env.SYSTEM_PULLREQUEST_PULLREQUESTID && env.SYSTEM_PULLREQUEST_PULLREQUESTID !== 'false'),
root: env.BUILD_REPOSITORY_LOCALPATH,
};
},
};
// http://devcenter.wercker.com/docs/environment-variables/available-env-vars#hs_cos_wrapper_name
module.exports = {
detect() {
return Boolean(process.env.WERCKER_MAIN_PIPELINE_STARTED);
detect({env}) {
return Boolean(env.WERCKER_MAIN_PIPELINE_STARTED);
},
configuration() {
configuration({env}) {
return {
name: 'Wercker',
service: 'wercker',
commit: process.env.WERCKER_GIT_COMMIT,
build: process.env.WERCKER_MAIN_PIPELINE_STARTED,
buildUrl: process.env.WERCKER_RUN_URL,
branch: process.env.WERCKER_GIT_BRANCH,
slug: `${process.env.WERCKER_GIT_OWNER}/${process.env.WERCKER_GIT_REPOSITORY}`,
root: process.env.WERCKER_ROOT,
commit: env.WERCKER_GIT_COMMIT,
build: env.WERCKER_MAIN_PIPELINE_STARTED,
buildUrl: env.WERCKER_RUN_URL,
branch: env.WERCKER_GIT_BRANCH,
slug: `${env.WERCKER_GIT_OWNER}/${env.WERCKER_GIT_REPOSITORY}`,
root: env.WERCKER_ROOT,
};
},
};
{
"name": "env-ci",
"description": "Get environment variables exposed by CI services",
"version": "2.3.0",
"version": "2.4.0",
"author": "Pierre Vanduynslager (https://github.com/pvdlg)",

@@ -18,2 +18,3 @@ "bugs": {

"nyc": "^12.0.1",
"proxyquire": "^2.1.0",
"semantic-release": "^15.0.0",

@@ -20,0 +21,0 @@ "tempy": "^0.2.1",

@@ -37,3 +37,3 @@ # env-ci

## Variables
## Supported variables

@@ -56,2 +56,4 @@ | Variable | Description |

**Note**: Some variables can be detected only on certain CI services. See [Supported CI](#supported-ci).
## Supported CI

@@ -81,4 +83,32 @@

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.
**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`<br>
Default: `process.env`
The object to read environment variables from.
#### cwd
Type: `String`<br>
Default: `process.cwd()`
The current working directory in which to execute `git` commands used to determine the `commit` and `branch` [Result](#result) properties in case no [supported CI](#supported-ci) is detected.
### Result
Type: `Object`
[Environment variables values](#supported-variables) exposed by the CI service.
## Caveats

@@ -85,0 +115,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc