How to detect if test is running on GitLab CI server

RichardK :

I have a test, which is using MySQL database configured and running on gitlab CI server (gitlab-ci.yml). I want that test to be disabled when it's running locally (it's using in-memory database instead). Is there any way to check if the test is running on GitLab Ci server? Something like:

if(isRunningOnGitlabCi()) {
  Assert.assertThat(...);
}

Maybe there's environmental variable, which I can check ?

wilddev :

On Gitlab-ci there is a predefined environment variable "GITLAB_CI"

https://docs.gitlab.com/ee/ci/variables/#predefined-variables-environment-variables

you should check it with System.getenv("GITLAB_CI")!=null;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=73630&siteId=1