{"name":"env-ci","description":"Get environment variables exposed by CI services","version":"11.2.0","author":{"name":"Pierre Vanduynslager","url":"https://github.com/pvdlg"},"type":"module","exports":"./index.js","dependencies":{"execa":"^8.0.0","java-properties":"^1.0.2"},"devDependencies":{"ava":"6.4.1","c8":"10.1.3","file-url":"4.0.0","prettier":"3.6.2","tempy":"3.1.0"},"engines":{"node":"^18.17 || >=20.6.1"},"keywords":["appveyor","azure-pipelines","bamboo","bitbucket","bitrise","buddy","buildkite","ci","circle","cirrus","cloudflare","codebuild","codefresh","codeship","drone","environment","git","github","gitlab","jenkins","netlify","puppet","sail","screwdriver","scrutinizer","semaphore","shippable","teamcity","travis","variable","wercker","woodpecker"],"license":"MIT","publishConfig":{"access":"public","provenance":true},"repository":{"type":"git","url":"git+https://github.com/semantic-release/env-ci.git"},"scripts":{"lint":"prettier --check \"*.{js,json,md}\" \".github/**/*.{md,yml}\" \"{lib,services,test}/**/*.js\"","lint:fix":"prettier --write \"*.{js,json,md}\" \".github/**/*.{md,yml}\" \"{lib,services,test}/**/*.js\"","semantic-release":"semantic-release","test":"npm run lint && npm run test:ci","test:ci":"c8 ava --verbose"},"renovate":{"extends":["github>semantic-release/.github:renovate-config"]},"_id":"env-ci@11.2.0","gitHead":"6c0e0e37e3a0d3686e4f2f44a130d69a8d098d23","bugs":{"url":"https://github.com/semantic-release/env-ci/issues"},"homepage":"https://github.com/semantic-release/env-ci#readme","_nodeVersion":"22.18.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-D5kWfzkmaOQDioPmiviWAVtKmpPT4/iJmMVQxWxMPJTFyTkdc5JQUfc5iXEeWxcOdsYTKSAiA/Age4NUOqKsRA==","shasum":"e7386afdf752962c587e7f3d3fb64d87d68e82c6","tarball":"http://registry-npm.ywwl.com/env-ci/download/env-ci-11.2.0.tgz","fileCount":38,"unpackedSize":53515,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/env-ci@11.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDbP9D/XoqOy54iVrVKsTiPml2iPIK/Aqjujp4RR+bdlAiBD8vDpL5KXtf9gRod4RS66shXof7VuAJhOB9bVJtI9qw=="}],"size":12115,"noattachment":false,"key":"/env-ci/-/env-ci-11.2.0.tgz"},"_npmUser":{"name":"semantic-release-bot","email":"semantic-release@martynus.net"},"directories":{},"maintainers":[{"name":"pvdlg","email":"pierre.denis.vanduynslager@gmail.com"},{"name":"semantic-release-bot","email":"semantic-release@martynus.net"},{"name":"gr2m","email":"gregor@martynus.net"},{"name":"travi","email":"npm@travi.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/env-ci_11.2.0_1756740806166_0.7505934083296302"},"_hasShrinkwrap":false,"readme":"# env-ci\n\nGet environment variables exposed by CI services.\n\n[![Build Status](https://github.com/semantic-release/env-ci/workflows/Test/badge.svg)](https://github.com/semantic-release/env-ci/actions?query=workflow%3ATest+branch%3Amaster)\n[![npm latest version](https://img.shields.io/npm/v/env-ci/latest.svg)](https://www.npmjs.com/package/env-ci)\n\nAdapted from [codecov-node](https://github.com/codecov/codecov-node/blob/master/lib/detect.js).\n\n## Install\n\n```bash\n$ npm install --save env-ci\n```\n\n## Usage\n\n```js\nimport envCi from \"env-ci\";\n\nconst {\n  name,\n  service,\n  isCi,\n  branch,\n  commit,\n  tag,\n  build,\n  buildUrl,\n  job,\n  jobUrl,\n  isPr,\n  pr,\n  prBranch,\n  slug,\n  root,\n} = envCi();\n\nif (isCI) {\n  console.log(`Building repo ${slug} on ${name} service`);\n\n  if (isPr) {\n    console.log(\n      `Building Pull Request #${pr} originating from branch ${prBranch} and targeting branch ${branch}`,\n    );\n  } else {\n    console.log(`Building branch ${branch}`);\n  }\n\n  if (service === \"travis\") {\n    // Do something specific to Travis CI\n  }\n}\n```\n\n## Supported variables\n\n| Variable   | Description                                                                                            |\n| ---------- | ------------------------------------------------------------------------------------------------------ |\n| `name`     | CI service Commercial name (e.g. `Travis CI`, `CircleCI`, `GitLab CI/CD`)                              |\n| `service`  | Standardized CI service name (e.g. `travis`, `circleci`, `gitlab`)                                     |\n| `isCi`     | `true` is running on a CI, `false` otherwise                                                           |\n| `branch`   | Git branch being built or targeted by a Pull Request                                                   |\n| `commit`   | Commit sha that triggered the CI build                                                                 |\n| `tag`      | Git tag that triggered the CI build                                                                    |\n| `build`    | CI service build number                                                                                |\n| `buildUrl` | Link to the CI service build                                                                           |\n| `job`      | CI service job number                                                                                  |\n| `jobUrl`   | Link to the CI service job                                                                             |\n| `isPr`     | `true` if the build has been triggered by a Pull Request, `false` otherwise                            |\n| `pr`       | Pull Request number (only for builds triggered by a Pull Request)                                      |\n| `prBranch` | Git branch branch from which the Pull Request originated (only for builds triggered by a Pull Request) |\n| `slug`     | The slug (in form: owner_name/repo_name) of the repository currently being built                       |\n| `root`     | The path to the directory where the repository is being built                                          |\n\n**Note**: Some variables can be detected only on certain CI services. See [Supported CI](#supported-ci).\n\n**Note**: The `pr` and `prBranch` properties are only available for builds triggered when a Pull Request is\nopened/updated and not on builds triggered by a push on a branch even if that branch happens to be the branch from which\nthe Pull Request originated.\n\n## Supported CI\n\n| CI Service (`name`)                                                                                                                    |     `service`     |       `isCi`       |          `branch`           |      `commit`      |          `tag`          |      `build`       |     `buildUrl`     |       `job`        |      `jobUrl`      |        `isPr`         |         `pr`          |      `prBranch`       |       `slug`       |       `root`       |\n| -------------------------------------------------------------------------------------------------------------------------------------- | :---------------: | :----------------: | :-------------------------: | :----------------: | :---------------------: | :----------------: | :----------------: | :----------------: | :----------------: | :-------------------: | :-------------------: | :-------------------: | :----------------: | :----------------: |\n| [AppVeyor](https://www.appveyor.com/docs/environment-variables)                                                                        |    `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: |\n| [Azure Pipelines](https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables)                                             |  `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: |\n| [Bamboo](https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html)                                                      |     `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: |\n| [Bitbucket](https://confluence.atlassian.com/bitbucket/environment-variables-794502608.html)                                           |    `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: |\n| [Bitrise](https://devcenter.bitrise.io/builds/available-environment-variables/#exposed-by-bitriseio)                                   |     `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:         |\n| [Buddy](https://buddy.works/knowledge/deployments/how-use-environment-variables#default-environment-variables)                         |      `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:         |\n| [Buildkite](https://buildkite.com/docs/builds/environment-variables)                                                                   |    `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: |\n| [CircleCI](https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables)                                                     |    `circleci`     | :white_check_mark: |   [:warning:](#circleci)    | :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:         |\n| [Cirrus CI](https://cirrus-ci.org/guide/writing-tasks/#environment-variables)                                                          |     `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: |\n| [Cloudflare Pages](https://developers.cloudflare.com/pages/platform/build-configuration#environment-variables)                         | `cloudflarePages` | :white_check_mark: |     :white_check_mark:      | :white_check_mark: |           :x:           |        :x:         |        :x:         |        :x:         |        :x:         |          :x:          |          :x:          |          :x:          |        :x:         | :white_check_mark: |\n| [AWS CodeBuild](https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html)                                    |    `codebuild`    | :white_check_mark: | [:warning:](#aws-codebuild) | :white_check_mark: |           :x:           | :white_check_mark: | :white_check_mark: |        :x:         |        :x:         |          :x:          |          :x:          |          :x:          |        :x:         | :white_check_mark: |\n| [Codefresh](https://codefresh.io/docs/docs/codefresh-yaml/variables#system-provided-variables)                                         |    `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: |\n| [Codeship](https://documentation.codeship.com/basic/builds-and-configuration/set-environment-variables/#default-environment-variables) |    `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:         |\n| [Drone](https://readme.drone.io/reference/environ/)                                                                                    |      `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: |\n| [GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables)          |     `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: |\n| [GitLab CI/CD](https://docs.gitlab.com/ce/ci/variables/README.html)                                                                    |     `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: |\n| [Jenkins](https://wiki.jenkins.io/display/JENKINS/Building+a+software+project)                                                         |     `jenkins`     | :white_check_mark: |    [:warning:](#jenkins)    | :white_check_mark: |           :x:           | :white_check_mark: | :white_check_mark: |        :x:         |        :x:         | [:warning:](#jenkins) | [:warning:](#jenkins) | [:warning:](#jenkins) | :white_check_mark: | :white_check_mark: |\n| [Netlify](https://docs.netlify.com/configure-builds/environment-variables/#netlify-configuration-variables)                            |     `netlify`     | :white_check_mark: |    [:warning:](#netlify)    | :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: |\n| [Puppet](https://puppet.com/docs/pipelines-for-apps/enterprise/environment-variable.html)                                              |     `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: |\n| [Sail CI](https://sail.ci/docs/environment-variables)                                                                                  |      `sail`       | :white_check_mark: |     [:warning:](#sail)      | :white_check_mark: |           :x:           |        :x:         |        :x:         |        :x:         |        :x:         |  :white_check_mark:   |  :white_check_mark:   |          :x:          | :white_check_mark: | :white_check_mark: |\n| [Screwdriver.cd](https://docs.screwdriver.cd/user-guide/environment-variables)                                                         |   `screwdriver`   | :white_check_mark: |  [:warning:](#screwdriver)  | :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: |\n| [Scrutinizer](https://scrutinizer-ci.com/docs/build/environment-variables)                                                             |   `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:         |\n| [Semaphore](https://docs.semaphoreci.com/article/12-environment-variables)                                                             |    `semaphore`    | :white_check_mark: |   [:warning:](#semaphore)   | :white_check_mark: | [:warning:](#semaphore) | :white_check_mark: |        :x:         |        :x:         |        :x:         |  :white_check_mark:   |  :white_check_mark:   |  :white_check_mark:   | :white_check_mark: | :white_check_mark: |\n| [Shippable](http://docs.shippable.com/ci/env-vars/#stdEnv)                                                                             |    `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: |\n| [TeamCity](https://confluence.jetbrains.com/display/TCD10/Predefined+Build+Parameters)                                                 |    `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: |\n| [Travis CI](https://docs.travis-ci.com/user/environment-variables#default-environment-variables)                                       |     `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: |\n| [Vela](https://go-vela.github.io/docs/reference/environment/variables/)                                                                |      `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: |\n| [Vercel](https://vercel.com/docs/environment-variables)                                                                                |     `vercel`      | :white_check_mark: |     :white_check_mark:      | :white_check_mark: |           :x:           |        :x:         |        :x:         |        :x:         |        :x:         |          :x:          |          :x:          |          :x:          | :white_check_mark: |        :x:         |\n| [Wercker](http://devcenter.wercker.com/docs/environment-variables/available-env-vars#hs_cos_wrapper_name)                              |     `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: |\n| [JetBrains Space](https://www.jetbrains.com/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:         |\n| [Woodpecker CI](https://woodpecker-ci.org/docs/usage/environment#built-in-environment-variables)                                       |   `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: |\n\n:warning: See [Caveats](#caveats)\n\n**Note**: Unsupported properties will always be `undefined`. For example if a Ci services doesn't support triggering\nbuilds when a Pull Request is opened/updated, `isPr` will be `undefined`.\n\n**Note**: If none of the above CI services is detected, `commit` and `branch` are determined based on the local Git\nrepository, and `isCi` is determined based on the `CI` environment variable.\n\n## API\n\n### envCi(options) => Result\n\n#### options\n\nType: `Object`\n\n#### env\n\nType: `Object`<br>\nDefault: `process.env`\n\nThe object to read environment variables from.\n\n#### cwd\n\nType: `String`<br>\nDefault: `process.cwd()`\n\nThe current working directory in which to execute `git` commands used to determine the `commit`\nand `branch` [Result](#result) properties in case no [supported CI](#supported-ci) is detected.\n\n### Result\n\nType: `Object`\n\n[Environment variables values](#supported-variables) exposed by the CI service.\n\n## Caveats\n\n### AWS CodeBuild\n\nAWS CodeBuild doesn't provide an environment variable to determine the current Git branch being built. In addition, it\nclones the repository in a [detached head state](https://git-scm.com/docs/git-checkout#_detached_head) so the branch\ncannot be determined with `git rev-parse --abbrev-ref HEAD`.\nTo work around this limitation, `env-ci` look for the remote branches having the same `HEAD` as the local\ndetached `HEAD` to determine the branch from which the detached `HEAD` was created.\nIn the rare case where there is multiple remote branches with the same `HEAD` as the local detached `HEAD`, `env-ci`\nwill arbitrarily pick the first one. This can lead to an inaccurate `branch` value in such circumstances.\n\n### CircleCI\n\nFor builds triggered when a Pull Request is opened/updated, CircleCI doesn't provide an environment variable indicating\nthe target branch.\nTherefore, in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` property.\nHowever `prBranch` will be set.\n\nSee [feature request](https://discuss.circleci.com/t/create-a-circle-target-branch-envar/10022).\n\n### Cloudflare Pages\n\nFor builds triggered when a Pull Request is opened/updated, Cloudflare Pages will re-use the branch variable for the\noriginating branch and not provide a target. Therefore `env-ci` will not be able to determine the `prBranch` property\nhowever `branch` will always be set.\n\n### Jenkins\n\nTriggering build when a Pull Request is opened/updated is supported only via\nthe [ghprb-plugin](https://github.com/jenkinsci/ghprb-plugin)\nand [gitlab-plugin](https://github.com/jenkinsci/gitlab-plugin). Therefore `env-ci` will set `isPr`, `pr` and `prBranch`\nand define `branch` with the Pull Request target branch only if one those plugin is used.\n\n### Netlify\n\nFor builds triggered when a Pull Request is opened/updated, Netlify doesn't provide an environment variable indicating\nthe target branch.\nTherefore, in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` property.\nHowever `prBranch` will be set.\n\nSee [feature request](https://answers.netlify.com/t/access-pr-target-branch-when-deploying-preview-build/32402)\n\n### Sail\n\nFor builds triggered when a Pull Request is opened/updated, Sail doesn't provide an environment variable indicating the\ntarget branch, and the one for the current branch is set to `pull/<PR number>` independently of the the branch name from\nwhich the Pull Request originated.\nTherefore, in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` and `prBranch`\nproperties.\n\n### Semaphore\n\nFor builds triggered when a Pull Request is opened/updated, Semaphore 1.0 doesn't provide an environment variable\nindicating the target branch.\nTherefore, in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` property.\nHowever `prBranch` will be set.\nOn Semaphore 2.0 the `branch` and `prBranch` properties will work as expected.\n\nThe property `tag` is only available on Semaphore 2.0.\n\n### Screwdriver\n\nFor builds triggered when a Pull Request is opened/updated, Screwdriver sets the `env.GIT_BRANCH` as `head:pr` branch\ntype (Example:`origin/refs/pull/1/head:pr`) while at commit level (non PR) it does set it with the actual branch (Example: `origin/main`).\n","publish_time":1756740806382,"_cnpm_publish_time":1756740806382,"dist-tags":{"beta":"8.0.1-beta.2","latest":"11.2.0"}}