Skip to content

Instantly share code, notes, and snippets.

@guruguruman
Last active September 18, 2018 01:43
Show Gist options
  • Save guruguruman/ce46105883d29c448ac1a9adf4a977d1 to your computer and use it in GitHub Desktop.
Save guruguruman/ce46105883d29c448ac1a9adf4a977d1 to your computer and use it in GitHub Desktop.
Determining TravisCI enviroment
class TravisCI {
/*
* check whether test is running on TravisCI or not using TravisCI enviroment variables.
*
* as for TravisCI enviroment variables availables @see https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
*
*/
static var isRunningOnTravisEnviroment: Bool {
let isTravisEnviromentVariableName = "CI"
let isCIEnviromentVariableName = "TRAVIS"
let enviromentVariables = ProcessInfo().environment
if
enviromentVariables.keys.contains(isCIEnviromentVariableName), enviromentVariables[isCIEnviromentVariableName] == "true",
enviromentVariables.keys.contains(isTravisEnviromentVariableName), enviromentVariables[isCIEnviromentVariableName] == "true" {
return true
}
return false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment