PHPackages                             ondram/ci-detector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [DevOps &amp; Deployment](/categories/devops)
4. /
5. ondram/ci-detector

ActiveLibrary[DevOps &amp; Deployment](/categories/devops)

ondram/ci-detector
==================

Detect continuous integration environment and provide unified access to properties of current build

4.2.0(2y ago)22249.4M—4.2%13[3 issues](https://github.com/OndraM/ci-detector/issues)[3 PRs](https://github.com/OndraM/ci-detector/pulls)20MITPHPPHP ^7.4 || ^8.0CI passing

Since Jul 29Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/OndraM/ci-detector)[ Packagist](https://packagist.org/packages/ondram/ci-detector)[ RSS](/packages/ondram-ci-detector/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (7)Versions (21)Used By (20)

CI Detector
===========

[](#ci-detector)

[![Latest Stable Version](https://camo.githubusercontent.com/5b5c54917ee33c5418a5f4dc28e273c8b24e8129569db1caf6a0889835310911/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6e6472616d2f63692d6465746563746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ondram/ci-detector)[![Packagist Downloads](https://camo.githubusercontent.com/c2b7726e10813eb2834adcca82974b6747b9f5cabb05bb7f7a56ef02dc547718/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f4f6e6472614d2f63692d6465746563746f723f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ondram/ci-detector)[![Coverage Status](https://camo.githubusercontent.com/089859d191fe7c8a7ecb950c3cc0fc6c04d545525c05022055fb7857792217bd/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f4f6e6472614d2f63692d6465746563746f722f6d61696e2e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/r/OndraM/ci-detector)[![GitHub Actions Build Status](https://camo.githubusercontent.com/8829118ca0289d259d8b4a1c28bb1090fb356f0bb836da0a1338f0d6e56ef400/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f4f6e6472614d2f63692d6465746563746f722f74657374732e79616d6c3f7374796c653d666c61742d737175617265266c6162656c3d476974487562253230416374696f6e732532306275696c64)](https://github.com/OndraM/ci-detector/actions)[![Travis Build Status](https://camo.githubusercontent.com/e08ea8b1dda7ef36caaf5b91ee4168967593ffa4c10d7b15f7beab9ae2c3834f/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f636f6d2f4f6e6472614d2f63692d6465746563746f722e7376673f7374796c653d666c61742d737175617265266c6162656c3d5472617669732532306275696c64)](https://app.travis-ci.com/OndraM/ci-detector)[![AppVeyor Build Status](https://camo.githubusercontent.com/3e146e99d921480ef2a72671bf34e7a2bb38b0230d908afca6e6517c27dc8101/68747470733a2f2f696d672e736869656c64732e696f2f6170707665796f722f63692f4f6e6472614d2f63692d6465746563746f722e7376673f7374796c653d666c61742d737175617265266c6162656c3d4170705665796f722532306275696c64)](https://ci.appveyor.com/project/OndraM/ci-detector)

PHP library to detect continuous integration environment and to read information of the current build.

Why
---

[](#why)

This library is useful if you need to detect whether some CLI script/tool is running in an automated environment (on a CI server). Based on that, your script may behave differently. For example, it could hide some information which relevant only for a real person - like a progress bar.

Additionally, you may want to detect some information about the current build: build ID, git commit, branch etc. For example, if you'd like to record these values to log, publish them to Slack, etc.

How
---

[](#how)

The detection is based on environment variables injected to the build environment by each CI server. However, these variables are named differently in each CI. This library contains adapters for many supported CI servers to handle these differences, so you can make your scripts (and especially CLI tools) portable to multiple build environments.

Supported continuous integration servers
----------------------------------------

[](#supported-continuous-integration-servers)

These CI servers are currently recognized:

- [AppVeyor](https://www.appveyor.com/)
- [AWS CodeBuild](https://aws.amazon.com/codebuild/)
- [Azure DevOps Pipelines](https://azure.microsoft.com/en-us/products/devops/pipelines)
- [Bamboo](https://www.atlassian.com/software/bamboo)
- [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines)
- [Buddy](https://buddy.works/)
- [CircleCI](https://circleci.com/)
- [Codeship](https://codeship.com/)
- continuousphp
- [drone](https://drone.io/)
- [GitHub Actions](https://github.com/features/actions)
- [GitLab](https://about.gitlab.com/solutions/continuous-integration/)
- [Jenkins](https://www.jenkins.io/)
- [SourceHut](https://sourcehut.org/)
- [TeamCity](https://www.jetbrains.com/teamcity/)
- [Travis CI](https://travis-ci.org/)
- Wercker

If your favorite CI server is missing, feel free to send a pull-request!

Installation
------------

[](#installation)

Install using [Composer](https://getcomposer.org/):

```
$ composer require ondram/ci-detector
```

Example usage
-------------

[](#example-usage)

```
