Skip to content

Commit

Permalink
fix: Add verbose env var names
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasrockhu-codecov committed Jul 31, 2021
1 parent 241448e commit fbbf728
Show file tree
Hide file tree
Showing 18 changed files with 221 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/ci_providers/provider_appveyorci.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,26 @@ function getServiceParams(inputs) {
}
}

function getEnvVarNames() {
return [
'APPVEYOR',
'APPVEYOR_ACCOUNT_NAME',
'APPVEYOR_BUILD_ID',
'APPVEYOR_BUILD_VERSION',
'APPVEYOR_JOB_ID',
'APPVEYOR_PROJECT_SLUG',
'APPVEYOR_PULL_REQUEST_NUMBER',
'APPVEYOR_REPO_BRANCH',
'APPVEYOR_REPO_COMMIT',
'APPVEYOR_REPO_NAME',
'APPVEYOR_URL',
'CI',
]
}

module.exports = {
detect,
getEnvVarNames,
getServiceName,
getServiceParams,
}
14 changes: 14 additions & 0 deletions src/ci_providers/provider_azurepipelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,22 @@ function getServiceParams(inputs) {
}
}

function getEnvVarNames() {
return [
'BUILD_BUILDID',
'BUILD_BUILDNUMBER',
'BUILD_SOURCEBRANCH',
'BUILD_SOURCEVERSION',
'SYSTEM_PULLREQUEST_PULLREQUESTID',
'SYSTEM_PULLREQUEST_PULLREQUESTNUMBER',
'SYSTEM_TEAMFOUNDATIONSERVERURI',
'SYSTEM_TEAMPROJECT',
]
}

module.exports = {
detect,
getEnvVarNames,
getServiceName,
getServiceParams,
}
13 changes: 13 additions & 0 deletions src/ci_providers/provider_bitbucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,21 @@ function getServiceParams(inputs) {
}
}

function getEnvVarNames() {
return [
'BITBUCKET_BRANCH',
'BITBUCKET_BUILD_NUMBER',
'BITBUCKET_COMMIT',
'BITBUCKET_PR_ID',
'BITBUCKET_REPO_OWNER',
'BITBUCKET_REPO_SLUG',
'CI',
]
}

module.exports = {
detect,
getEnvVarNames,
getServiceName,
getServiceParams,
}
13 changes: 13 additions & 0 deletions src/ci_providers/provider_buildkite.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,21 @@ function getServiceParams(inputs) {
}
}

function getEnvVarNames() {
return [
'BUILDKITE',
'BUILDKITE_BRANCH',
'BUILDKITE_BUILD_NUMBER',
'BUILDKITE_BUILD_URL',
'BUILDKITE_COMMIT',
'BUILDKITE_JOB_ID',
'BUILDKITE_PROJECT_SLUG',
]
}

module.exports = {
detect,
getEnvVarNames,
getServiceName,
getServiceParams,
}
16 changes: 16 additions & 0 deletions src/ci_providers/provider_circleci.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,24 @@ function getServiceParams(inputs) {
}
}

function getEnvVarNames() {
return [
'CI',
'CIRCLECI',
'CIRCLE_BRANCH',
'CIRCLE_BUILD_NUM',
'CIRCLE_NODE_INDEX',
'CIRCLE_PROJECT_REPONAME',
'CIRCLE_PROJECT_USERNAME',
'CIRCLE_PR_NUMBER',
'CIRCLE_REPOSITORY_URL',
'CIRCLE_SHA1',
]
}

module.exports = {
detect,
getEnvVarNames,
getServiceName,
getServiceParams,
}
13 changes: 13 additions & 0 deletions src/ci_providers/provider_cirrus.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,21 @@ function getServiceParams(inputs) {
}
}

function getEnvVarNames() {
return [
'CIRRUS_BRANCH',
'CIRRUS_BUILD_ID',
'CIRRUS_CHANGE_IN_REPO',
'CIRRUS_CI',
'CIRRUS_PR',
'CIRRUS_REPO_FULL_NAME',
'CIRRUS_TASK_ID',
]
}

module.exports = {
detect,
getEnvVarNames,
getServiceName,
getServiceParams,
}
12 changes: 12 additions & 0 deletions src/ci_providers/provider_codebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,20 @@ function getServiceParams(inputs) {
}
}

function getEnvVarNames() {
return [
'CODEBUILD_BUILD_ID',
'CODEBUILD_CI',
'CODEBUILD_RESOLVED_SOURCE_VERSION',
'CODEBUILD_SOURCE_REPO_URL',
'CODEBUILD_SOURCE_VERSION',
'CODEBUILD_WEBHOOK_HEAD_REF',
]
}

module.exports = {
detect,
getEnvVarNames,
getServiceName,
getServiceParams,
}
13 changes: 13 additions & 0 deletions src/ci_providers/provider_drone.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,21 @@ function getServiceParams(inputs) {
}
}

function getEnvVarNames() {
return [
'DRONE',
'DRONE_BRANCH',
'DRONE_BUILD_NUMBER',
'DRONE_BUILD_URL',
'DRONE_COMMIT_SHA',
'DRONE_PULL_REQUEST',
'DRONE_REPO_LINK',
]
}

module.exports = {
detect,
getEnvVarNames,
getServiceName,
getServiceParams,
}
14 changes: 14 additions & 0 deletions src/ci_providers/provider_githubactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,22 @@ function getServiceParams(inputs) {
}
}

function getEnvVarNames() {
return [
'GITHUB_ACTION',
'GITHUB_HEAD_REF',
'GITHUB_REF',
'GITHUB_REPOSITORY',
'GITHUB_RUN_ID',
'GITHUB_SERVER_URL',
'GITHUB_SHA',
'GITHUB_WORKFLOW',
]
}

module.exports = {
detect,
getEnvVarNames,
getServiceName,
getServiceParams,
}
16 changes: 16 additions & 0 deletions src/ci_providers/provider_gitlabci.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,24 @@ function getServiceParams(inputs) {
}
}

function getEnvVarNames() {
return [
'CI_BUILD_ID',
'CI_BUILD_REF',
'CI_BUILD_REF_NAME',
'CI_BUILD_REPO',
'CI_COMMIT_REF_NAME',
'CI_COMMIT_SHA',
'CI_JOB_ID',
'CI_PROJECT_PATH',
'CI_REPOSITORY_URL',
'GITLAB_CI',
]
}

module.exports = {
detect,
getEnvVarNames,
getServiceName,
getServiceParams,
}
16 changes: 16 additions & 0 deletions src/ci_providers/provider_jenkinsci.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,24 @@ function getServiceParams(inputs) {
}
}

function getEnvVarNames() {
return [
'BRANCH_NAME',
'BUILD_NUMBER',
'BUILD_URL',
'CHANGE_ID',
'GIT_BRANCH',
'GIT_COMMIT',
'JENKINS_URL',
'ghprbActualCommit',
'ghprbPullId',
'ghprbSourceBranch',
]
}

module.exports = {
detect,
getEnvVarNames,
getServiceName,
getServiceParams,
}
5 changes: 5 additions & 0 deletions src/ci_providers/provider_local.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,13 @@ function getServiceParams(inputs) {
}
}

function getEnvVarNames() {
return ['CI']
}

module.exports = {
detect,
getEnvVarNames,
getServiceName,
getServiceParams,
}
5 changes: 5 additions & 0 deletions src/ci_providers/provider_teamcity.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ function getServiceParams(inputs) {
}
}

function getEnvVarNames() {
return ['BRANCH_NAME', 'BUILD_NUMBER', 'BUILD_VCS_NUMBER', 'TEAMCITY_VERSION']
}

module.exports = {
detect,
getEnvVarNames,
getServiceName,
getServiceParams,
}
10 changes: 10 additions & 0 deletions src/ci_providers/provider_template.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,18 @@ function getServiceParams(inputs) {
}
}

/**
* Returns all the environment variables used by the provider
*
* @returns [{string}]
*/
function getEnvVarNames() {
return []
}

module.exports = {
detect,
getEnvVarNames,
getServiceName,
getServiceParams,
}
18 changes: 18 additions & 0 deletions src/ci_providers/provider_travisci.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,26 @@ function getServiceParams(inputs) {
}
}

function getEnvVarNames() {
return [
'CI',
'SHIPPABLE',
'TRAVIS',
'TRAVIS_BRANCH',
'TRAVIS_COMMIT',
'TRAVIS_JOB_ID',
'TRAVIS_JOB_NUMBER',
'TRAVIS_PULL_REQUEST',
'TRAVIS_PULL_REQUEST_BRANCH',
'TRAVIS_PULL_REQUEST_SHA',
'TRAVIS_REPO_SLUG',
'TRAVIS_TAG',
]
}

module.exports = {
detect,
getEnvVarNames,
getServiceName,
getServiceParams,
}
12 changes: 12 additions & 0 deletions src/ci_providers/provider_wercker.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,20 @@ function getServiceParams(inputs) {
}
}

function getEnvVarNames() {
return [
'WERCKER_BUILD_URL',
'WERCKER_GIT_BRANCH',
'WERCKER_GIT_COMMIT',
'WERCKER_GIT_OWNER',
'WERCKER_GIT_REPOSITORY',
'WERCKER_MAIN_PIPELINE_STARTED',
]
}

module.exports = {
detect,
getEnvVarNames,
getServiceName,
getServiceParams,
}
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ async function main(args) {
for (const provider of providers) {
if (provider.detect(envs)) {
info(`Detected ${provider.getServiceName()} as the CI provider.`)
verbose('-> Using the following env variables:', args.verbose)
for (const envVarName of provider.getEnvVarNames()) {
verbose(` ${envVarName}: ${envs[envVarName]}`, args.verbose)
}
serviceParams = provider.getServiceParams(inputs)
break
}
Expand Down
9 changes: 9 additions & 0 deletions test/providers/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,14 @@ describe('CI Providers', () => {
expect(typeof provider.getServiceName()).toBe('string')
expect(provider.getServiceName()).not.toBe('')
})

it('has env var names', () => {
const envVarNames = provider.getEnvVarNames()
expect(typeof envVarNames).toBe('object')
expect(envVarNames.length).toBeGreaterThan(0)
for (const envVarName of envVarNames) {
expect(typeof envVarName).toBe('string')
}
})
})
})

0 comments on commit fbbf728

Please sign in to comment.