Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do detect if Travis-Ci or not

Tags:

travis-ci

I need a way to determine if the person calling the function is Travis-CI or not. If it is Travis-CI, I do not want to start a session here. Right now, I have my tests script create a file called test.txt and then look for it.

protected function __construct() {     if ( (!session_id()) && (!file_exists('test.txt' ))) session_start(); } 

However, there has to be a better way. It seems, that without the file check, if there is in fact a session made, a new one will not be created. But this is not the case. If this was the case, the before link below should have passed.

Before the addition of the "test.txt" file:
After

like image 816
chriscct7 Avatar asked Oct 19 '12 22:10

chriscct7


People also ask

What is the purpose of Travis CI?

As a continuous integration platform, Travis CI supports your development process by automatically building and testing code changes, providing immediate feedback on the success of the change. Travis CI can also automate other parts of your development process by managing deployments and notifications.

Which of the following file is used to configure the Travis CI?

Configuration. Travis CI is configured by adding a file named . travis. yml , which is a YAML format text file, to the root directory of the repository.


1 Answers

In general you can detect if you are on Travis-CI by checking the environment variables. You can check either for CI=true or the more specific TRAVIS=true. In PHP you can use the getenv() function to get the value of an environment variable.

See the complete list of the environment. You can set even more env variables in your .travis.yml.

like image 112
Odi Avatar answered Sep 21 '22 22:09

Odi