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 1.4.1 to 1.4.2

40

index.js

@@ -6,25 +6,25 @@ 'use strict';

const services = {
appveyor: require('./lib/appveyor'),
bamboo: require('./lib/bamboo'),
bitrise: require('./lib/bitrise'),
buildkite: require('./lib/buildkite'),
circleci: require('./lib/circleci'),
codeship: require('./lib/codeship'),
drone: require('./lib/drone'),
gitlab: require('./lib/gitlab'),
jenkins: require('./lib/jenkins'),
semaphore: require('./lib/semaphore'),
shippable: require('./lib/shippable'),
teamcity: require('./lib/teamcity'),
travis: require('./lib/travis'),
wercker: require('./lib/wercker'),
appveyor: require('./lib/appveyor'),
bamboo: require('./lib/bamboo'),
bitrise: require('./lib/bitrise'),
buildkite: require('./lib/buildkite'),
circleci: require('./lib/circleci'),
codeship: require('./lib/codeship'),
drone: require('./lib/drone'),
gitlab: require('./lib/gitlab'),
jenkins: require('./lib/jenkins'),
semaphore: require('./lib/semaphore'),
shippable: require('./lib/shippable'),
teamcity: require('./lib/teamcity'),
travis: require('./lib/travis'),
wercker: require('./lib/wercker'),
};
module.exports = () => {
for (const name of Object.keys(services)) {
if (services[name].detect()) {
return Object.assign({isCi: true}, services[name].configuration());
}
}
return Object.assign({isCi: Boolean(process.env.CI)}, git.configuration());
for (const name of Object.keys(services)) {
if (services[name].detect()) {
return Object.assign({isCi: true}, services[name].configuration());
}
}
return Object.assign({isCi: Boolean(process.env.CI)}, git.configuration());
};
// https://www.appveyor.com/docs/environment-variables
module.exports = {
detect() {
return Boolean(process.env.APPVEYOR);
},
configuration() {
return {
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,
};
},
detect() {
return Boolean(process.env.APPVEYOR);
},
configuration() {
return {
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,
};
},
};
// https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html
module.exports = {
detect() {
// eslint-disable-next-line camelcase
return Boolean(process.env.bamboo_agentId);
},
configuration() {
return {
service: 'bamboo',
/* eslint-disable camelcase */
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,
/* eslint-enable camelcase */
};
},
detect() {
// eslint-disable-next-line camelcase
return Boolean(process.env.bamboo_agentId);
},
configuration() {
return {
service: 'bamboo',
/* eslint-disable camelcase */
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,
/* eslint-enable camelcase */
};
},
};
// http://devcenter.bitrise.io/faq/available-environment-variables
module.exports = {
detect() {
return Boolean(process.env.BITRISE_IO);
},
configuration() {
return {
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: process.env.BITRISE_PULL_REQUEST && process.env.BITRISE_PULL_REQUEST !== 'false',
slug: process.env.BITRISE_APP_SLUG,
};
},
detect() {
return Boolean(process.env.BITRISE_IO);
},
configuration() {
return {
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: process.env.BITRISE_PULL_REQUEST && process.env.BITRISE_PULL_REQUEST !== 'false',
slug: process.env.BITRISE_APP_SLUG,
};
},
};
// https://buildkite.com/docs/builds/environment-variables
module.exports = {
detect() {
return Boolean(process.env.BUILDKITE);
},
configuration() {
return {
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: process.env.BUILDKITE_PULL_REQUEST && process.env.BUILDKITE_PULL_REQUEST !== 'false',
root: process.env.BUILDKITE_BUILD_CHECKOUT_PATH,
};
},
detect() {
return Boolean(process.env.BUILDKITE);
},
configuration() {
return {
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: process.env.BUILDKITE_PULL_REQUEST && process.env.BUILDKITE_PULL_REQUEST !== 'false',
root: process.env.BUILDKITE_BUILD_CHECKOUT_PATH,
};
},
};
// https://circleci.com/docs/1.0/environment-variables
module.exports = {
detect() {
return Boolean(process.env.CIRCLECI);
},
configuration() {
return {
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,
pr: process.env.CI_PULL_REQUEST ? process.env.CI_PULL_REQUEST.split('/').pop() : undefined,
isPr: Boolean(process.env.CI_PULL_REQUEST),
slug: `${process.env.CIRCLE_PROJECT_USERNAME}/${process.env.CIRCLE_PROJECT_REPONAME}`,
};
},
detect() {
return Boolean(process.env.CIRCLECI);
},
configuration() {
return {
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,
pr: process.env.CI_PULL_REQUEST ? process.env.CI_PULL_REQUEST.split('/').pop() : undefined,
isPr: Boolean(process.env.CI_PULL_REQUEST),
slug: `${process.env.CIRCLE_PROJECT_USERNAME}/${process.env.CIRCLE_PROJECT_REPONAME}`,
};
},
};
// https://documentation.codeship.com/basic/builds-and-configuration/set-environment-variables
module.exports = {
detect() {
return process.env.CI_NAME && process.env.CI_NAME === 'codeship';
},
configuration() {
return {
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,
};
},
detect() {
return process.env.CI_NAME && process.env.CI_NAME === 'codeship';
},
configuration() {
return {
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,
};
},
};
// http://readme.drone.io/0.5/usage/environment-reference
module.exports = {
detect() {
return Boolean(process.env.DRONE);
},
configuration() {
return {
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}`,
};
},
detect() {
return Boolean(process.env.DRONE);
},
configuration() {
return {
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}`,
};
},
};
const execa = require('execa');
function configuration() {
return {
commit: head(),
branch: branch(),
};
return {
commit: head(),
branch: branch(),
};
}
function head() {
try {
return execa.sync('git', ['rev-parse', 'HEAD']).stdout;
} catch (err) {
return undefined;
}
try {
return execa.sync('git', ['rev-parse', 'HEAD']).stdout;
} catch (err) {
return undefined;
}
}
function branch() {
try {
return execa.sync('git', ['rev-parse', '--abbrev-ref', 'HEAD']).stdout;
} catch (err) {
return undefined;
}
try {
return execa.sync('git', ['rev-parse', '--abbrev-ref', 'HEAD']).stdout;
} catch (err) {
return undefined;
}
}
module.exports = {configuration, head, branch};
// https://docs.gitlab.com/ce/ci/variables/README.html
module.exports = {
detect() {
return Boolean(process.env.GITLAB_CI);
},
configuration() {
return {
service: 'gitlab',
commit: process.env.CI_COMMIT_SHA,
build: process.env.CI_JOB_NAME,
buildUrl: `${process.env.CI_PROJECT_URL}/pipelines/${process.env.CI_PIPELINE_ID}`,
job: process.env.CI_JOB_STAGE,
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,
};
},
detect() {
return Boolean(process.env.GITLAB_CI);
},
configuration() {
return {
service: 'gitlab',
commit: process.env.CI_COMMIT_SHA,
build: process.env.CI_JOB_NAME,
buildUrl: `${process.env.CI_PROJECT_URL}/pipelines/${process.env.CI_PIPELINE_ID}`,
job: process.env.CI_JOB_STAGE,
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,
};
},
};

@@ -6,21 +6,21 @@ const git = require('../lib/git');

module.exports = {
detect() {
return Boolean(process.env.JENKINS_URL);
},
configuration() {
return {
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),
};
},
detect() {
return Boolean(process.env.JENKINS_URL);
},
configuration() {
return {
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),
};
},
};

@@ -6,17 +6,17 @@ const git = require('../lib/git');

module.exports = {
detect() {
return Boolean(process.env.SEMAPHORE);
},
configuration() {
return {
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),
slug: process.env.SEMAPHORE_REPO_SLUG,
root: process.env.SEMAPHORE_PROJECT_DIR,
};
},
detect() {
return Boolean(process.env.SEMAPHORE);
},
configuration() {
return {
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),
slug: process.env.SEMAPHORE_REPO_SLUG,
root: process.env.SEMAPHORE_PROJECT_DIR,
};
},
};
// http://docs.shippable.com/ci/env-vars/#stdEnv
module.exports = {
detect() {
return Boolean(process.env.SHIPPABLE);
},
configuration() {
return {
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: process.env.IS_PULL_REQUEST && process.env.IS_PULL_REQUEST === 'true',
slug: process.env.SHIPPABLE_REPO_SLUG,
root: process.env.SHIPPABLE_BUILD_DIR,
};
},
detect() {
return Boolean(process.env.SHIPPABLE);
},
configuration() {
return {
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: process.env.IS_PULL_REQUEST && process.env.IS_PULL_REQUEST === 'true',
slug: process.env.SHIPPABLE_REPO_SLUG,
root: process.env.SHIPPABLE_BUILD_DIR,
};
},
};

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

function getProperties(env) {
const file = env.TEAMCITY_BUILD_PROPERTIES_FILE;
if (!file) {
return {};
}
const properties = javaProperties.of(file);
return {
root: properties.get('teamcity.build.workingDir'),
branch: properties.get('teamcity.build.branch'),
};
const file = env.TEAMCITY_BUILD_PROPERTIES_FILE;
if (!file) {
return {};
}
const properties = javaProperties.of(file);
return {
root: properties.get('teamcity.build.workingDir'),
branch: properties.get('teamcity.build.branch'),
};
}
module.exports = {
detect() {
return Boolean(process.env.TEAMCITY_VERSION);
},
configuration() {
return Object.assign(
{
service: 'teamcity',
commit: process.env.BUILD_VCS_NUMBER,
build: process.env.BUILD_NUMBER,
slug: process.env.TEAMCITY_BUILDCONF_NAME,
},
getProperties(process.env)
);
},
detect() {
return Boolean(process.env.TEAMCITY_VERSION);
},
configuration() {
return Object.assign(
{
service: 'teamcity',
commit: process.env.BUILD_VCS_NUMBER,
build: process.env.BUILD_NUMBER,
slug: process.env.TEAMCITY_BUILDCONF_NAME,
},
getProperties(process.env)
);
},
};
// https://docs.travis-ci.com/user/environment-variables
module.exports = {
detect() {
return Boolean(process.env.TRAVIS);
},
configuration() {
return {
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: process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false',
slug: process.env.TRAVIS_REPO_SLUG,
root: process.env.TRAVIS_BUILD_DIR,
};
},
detect() {
return Boolean(process.env.TRAVIS);
},
configuration() {
return {
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: process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false',
slug: process.env.TRAVIS_REPO_SLUG,
root: process.env.TRAVIS_BUILD_DIR,
};
},
};
// 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);
},
configuration() {
return {
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,
};
},
detect() {
return Boolean(process.env.WERCKER_MAIN_PIPELINE_STARTED);
},
configuration() {
return {
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,
};
},
};
{
"name": "env-ci",
"description": "Get environment variables exposed by CI services",
"version": "1.4.1",
"version": "1.4.2",
"author": "Pierre Vanduynslager (https://github.com/pvdlg)",

@@ -10,3 +10,3 @@ "bugs": {

"dependencies": {
"execa": "^0.9.0",
"execa": "^0.10.0",
"java-properties": "^0.2.9"

@@ -17,9 +17,6 @@ },

"codecov": "^3.0.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-prettier": "^2.4.0",
"nyc": "^11.1.0",
"prettier": "~1.10.0",
"semantic-release": "^12.2.2",
"semantic-release": "^15.0.0",
"tempy": "^0.2.1",
"xo": "^0.18.2"
"xo": "^0.20.0"
},

@@ -68,6 +65,3 @@ "engines": {

"prettier": {
"printWidth": 120,
"singleQuote": true,
"bracketSpacing": false,
"trailingComma": "es5"
"printWidth": 120
},

@@ -88,6 +82,4 @@ "publishConfig": {

"xo": {
"extends": [
"plugin:prettier/recommended"
]
"prettier": true
}
}
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