{"id":14969267,"url":"https://github.com/cucumber/ci-environment","last_synced_at":"2025-04-05T19:11:01.809Z","repository":{"id":37017416,"uuid":"419129507","full_name":"cucumber/ci-environment","owner":"cucumber","description":"Detect CI Environment from environment variables","archived":false,"fork":false,"pushed_at":"2025-03-27T09:27:53.000Z","size":1597,"stargazers_count":11,"open_issues_count":8,"forks_count":7,"subscribers_count":69,"default_branch":"main","last_synced_at":"2025-03-31T19:04:59.629Z","etag":null,"topics":["continuous-delivery","continuous-integration","github-actions","gitlab-ci","go","java","javascript","jenkins","polyglot-release","python","ruby","tidelift"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cucumber.png","metadata":{"funding":{"open_collective":"cucumber","github":"cucumber"},"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-20T00:11:00.000Z","updated_at":"2025-03-27T09:27:25.000Z","dependencies_parsed_at":"2024-01-12T11:52:24.640Z","dependency_job_id":"b8a498c3-a807-4416-9e2c-3b59eacff584","html_url":"https://github.com/cucumber/ci-environment","commit_stats":{"total_commits":960,"total_committers":23,"mean_commits":41.73913043478261,"dds":0.453125,"last_synced_commit":"bf8dbfdc15d2858547335fb250d3a8bc43d81249"},"previous_names":["cucumber/create-meta"],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cucumber%2Fci-environment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cucumber%2Fci-environment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cucumber%2Fci-environment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cucumber%2Fci-environment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cucumber","download_url":"https://codeload.github.com/cucumber/ci-environment/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246906749,"owners_count":20852975,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["continuous-delivery","continuous-integration","github-actions","gitlab-ci","go","java","javascript","jenkins","polyglot-release","python","ruby","tidelift"],"created_at":"2024-09-24T13:41:27.794Z","updated_at":"2025-04-05T19:11:01.778Z","avatar_url":"https://github.com/cucumber.png","language":"Java","funding_links":["https://opencollective.com/cucumber","https://github.com/sponsors/cucumber"],"categories":[],"sub_categories":[],"readme":"# CiEnvironment\n\n[![test-java](https://github.com/cucumber/ci-environment/actions/workflows/test-java.yml/badge.svg)](https://github.com/cucumber/ci-environment/actions/workflows/test-java.yml)\n[![test-javascript](https://github.com/cucumber/ci-environment/actions/workflows/test-javascript.yml/badge.svg)](https://github.com/cucumber/ci-environment/actions/workflows/test-javascript.yml)\n[![test-ruby](https://github.com/cucumber/ci-environment/actions/workflows/test-ruby.yml/badge.svg)](https://github.com/cucumber/ci-environment/actions/workflows/test-ruby.yml)\n[![test-go](https://github.com/cucumber/ci-environment/actions/workflows/test-go.yml/badge.svg)](https://github.com/cucumber/ci-environment/actions/workflows/test-go.yml)\n\nThis library detects the CI environment based on environment variables defined\nby CI servers.\n\nIf a CI server is detected, a `CiEnvironment.json` struct is returned:\n\n```json\n{\n  \"name\": \"...\",\n  \"url\": \"...\",\n  \"buildNumber\": \"...\", // optional\n  \"git\": {              // optional\n    \"remote\": \"...\",\n    \"revision\": \"...\",\n    \"branch\": \"...\",    // optional\n    \"tag\": \"...\"        // optional\n  }\n}\n```\n\nNote that some fields are optional (they may not be set if the corresponding environment\nvariables are not defined).\n\nSome CI servers expose usernames and passwords in the environment variable\nthat is used to detect `git.remote`. For security reasons, this library removes\nthe username and password from the `git.remote` field in the `CiEnvironment.json` struct.\n\n### TypeScript\n\n```shell\nnpm install @cucumber/ci-environment\n```\n\n```typescript\nimport detectCiEnvironment from '@cucumber/ci-environment'\n\nconst ciEnvironment = detectCiEnvironment(process.env)\nconsole.log(JSON.stringify(ciEnvironment, null, 2))\n```\n\n### Java\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.cucumber\u003c/groupId\u003e\n    \u003cartifactId\u003eci-environment\u003c/artifactId\u003e\n\u003c/dependency\u003e\n```\n\n```java\nimport static io.cucumber.cienvironment.DetectCiEnvironment.detectCiEnvironment;\n\npublic class CiEnvironmentExample {\n    public static void main(String[] args) {\n        CiEnvironment ciEnvironment = detectCiEnvironment(System.getenv()).orElseThrow(() -\u003e new RuntimeException(\"No CI environment detected\"));\n        System.out.println(\"ciEnvironment = \" + ciEnvironment);\n    }\n}\n```\n\n### Ruby\n\n```ruby\ngem 'cucumber-ci-environment'\n```\n\n```ruby\nrequire 'cucumber/ci_environment'\n\nci_environment = Cucumber::CiEnvironment.detect_ci_environment(ENV)\np ci_environment\n```\n\n### Go\n\n```shell\ngo get github.com/cucumber/ci-environment/go@latest\n```\n\n```Go\nimport (\n  \"fmt\"\n\tcienvironment \"github.com/cucumber/ci-environment/go\"\n)\n\nfunc main() {\n  ci := cienvironment.DetectCIEnvironment()\n  if ci == nil {\n    fmt.Println(\"No CI environment detected\")\n  }\n}\n```\n\n```python\nimport os\nfrom ci_environment import detect_ci_environment\n\nci_environment = detect_ci_environment(os.environ)\n```\n\n## Supported CI servers\n\n* [Azure Pipelines](https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?tabs=yaml\u0026view=azure-devops#build-variables)\n* [Bamboo](https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html)\n* [Buddy](https://buddy.works/docs/pipelines/environment-variables#default-environment-variables)\n* [Bitrise](https://devcenter.bitrise.io/builds/available-environment-variables/)\n* [CircleCI](https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables)\n* [CodeFresh](https://codefresh.io/docs/docs/codefresh-yaml/variables/#system-provided-variables)\n* [CodeShip](https://documentation.codeship.com/basic/builds-and-configuration/set-environment-variables/)\n* [GitHub Actions](https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables)\n* [GitLab](https://docs.gitlab.com/ee/ci/variables/predefined_variables.html)\n* [GoCD](https://docs.gocd.org/current/faq/dev_use_current_revision_in_build.html)\n* [Jenkins](https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables) and [Jenkins Git plugin](https://plugins.jenkins.io/git/#environment-variables)\n* [JetBrains Space](https://www.jetbrains.com/help/space/automation-parameters.html#use-provided-parameters)\n* [Semaphore](https://docs.semaphoreci.com/ci-cd-environment/environment-variables/)\n* [Travis CI](https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables)\n* [Wercker](https://devcenter.wercker.com/administration/environment-variables/available-env-vars/)\n\n## Contributing\n\nPlease see [CONTRIBUTING.md](./CONTRIBUTING.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcucumber%2Fci-environment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcucumber%2Fci-environment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcucumber%2Fci-environment/lists"}