Skip to content

Commit

Permalink
Merge pull request #14 from OndraM/feature/detect-other-ci-servers
Browse files Browse the repository at this point in the history
Detect other CI servers besides Jenkins
  • Loading branch information
OndraM committed May 24, 2015
2 parents 8e96561 + 8161708 commit 364aa1e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
24 changes: 24 additions & 0 deletions src/Console/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,28 @@ public function getDispatcher()
{
return $this->dispatcher;
}

/**
* Check if current environment is CI server.
*
* @codeCoverageIgnore The environment variables behavior is untestable
* @return bool|string False if not an CI server, name of the CI server otherwise
*/
protected function isCi()
{
$ciEnvVariables = [
'JENKINS_URL' => 'Jenkins CI',
'TRAVIS' => 'Travis CI',
'CIRCLECI' => 'CircleCI',
'TEAMCITY_VERSION ' => 'TeamCity',
];

foreach ($ciEnvVariables as $variable => $ciName) {
if (getenv($variable)) {
return $ciName;
}
}

return false;
}
}
2 changes: 1 addition & 1 deletion src/Console/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function ($answer) use ($latestVersionErrorMsg) {
sprintf(
'<info>Steward</info> <comment>%s</comment> is now downloading the Selenium standalone server...%s',
$this->getApplication()->getVersion(),
(!getenv('JOB_NAME') ? ' Just for you <fg=red><3</fg=red>!' : '')
(!$this->isCi() ? ' Just for you <fg=red><3</fg=red>!' : '')
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/RunTestsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
sprintf(
'<info>Steward</info> <comment>%s</comment> is running the tests...%s',
$this->getApplication()->getVersion(),
(!getenv('JOB_NAME') ? ' Just for you <fg=red><3</fg=red>!' : '') // in jenkins it is not just for you
(!$this->isCi() ? ' Just for you <fg=red><3</fg=red>!' : '') // on CI server it is not just for you
)
);

Expand Down

0 comments on commit 364aa1e

Please sign in to comment.