PHP code example of mcampbell508 / ci-detector
1. Go to this page and download the library: Download mcampbell508/ci-detector library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mcampbell508 / ci-detector example snippets
$ciDetector = new \OndraM\CiDetector\CiDetector();
if ($ciDetector->isCiDetected()) { // Make sure we are on CI environment
$ci = $ciDetector->detect(); // Returns class implementing CiInterface or throws CiNotDetectedException
// Example output when run in Travis:
echo $ci->getCiName(); // "Travis CI"
echo $ci->getBuildNumber(); // "35.1"
echo $ci->getBuildUrl(); // "https://travis-ci.org/OndraM/ci-detector/jobs/148395137"
echo $ci->getGitCommit(); // "fad3f7bdbf3515d1e9285b8aa80feeff74507bdd"
echo $ci->getGitBranch(); // "feature/foo-bar"
echo $ci->getRepositoryUrl(); // "" (empty string) - unsupported on Travis, will return eg. "ssh://git@gitserver:7999/project/repo.git" on Jenkins etc.)
} else {
echo "CI not detected";
}