Add new setting to determine if running in CI env

Fixes #3653
This commit is contained in:
Roman Iakovlev 2017-10-26 16:42:03 +02:00
parent 7e1a904b95
commit 5f143434a8
4 changed files with 15 additions and 6 deletions

View File

@ -273,6 +273,7 @@ object Defaults extends BuildCommon {
.toHex(Hash(appConfiguration.value.baseDirectory.toString))
.## % 1000),
serverAuthentication := Set(ServerAuthentication.Token),
insideCI :== sys.env.contains("BUILD_NUMBER") || sys.env.contains("CI"),
))
def defaultTestTasks(key: Scoped): Seq[Setting[_]] =
@ -1749,12 +1750,10 @@ object Classpaths {
dependencyOverrides :== Vector.empty,
libraryDependencies :== Nil,
excludeDependencies :== Nil,
ivyLoggingLevel :== {
// This will suppress "Resolving..." logs on Jenkins and Travis.
if (sys.env.get("BUILD_NUMBER").isDefined || sys.env.get("CI").isDefined)
UpdateLogging.Quiet
else UpdateLogging.Default
},
ivyLoggingLevel := (// This will suppress "Resolving..." logs on Jenkins and Travis.
if (insideCI.value)
UpdateLogging.Quiet
else UpdateLogging.Default),
ivyXML :== NodeSeq.Empty,
ivyValidate :== false,
moduleConfigurations :== Nil,

View File

@ -445,6 +445,7 @@ object Keys {
val skip = taskKey[Boolean]("For tasks that support it (currently only 'compile' and 'update'), setting skip to true will force the task to not to do its work. This exact semantics may vary by task.").withRank(BSetting)
val templateResolverInfos = settingKey[Seq[TemplateResolverInfo]]("Template resolvers used for 'new'.").withRank(BSetting)
val interactionService = taskKey[InteractionService]("Service used to ask for user input through the current user interface(s).").withRank(CTask)
val insideCI = SettingKey[Boolean]("insideCI", "Determines if the SBT is running in a Continuous Integration environment", AMinusSetting)
// special
val sessionVars = AttributeKey[SessionVar.Map]("sessionVars", "Bindings that exist for the duration of the session.", Invisible)

View File

@ -0,0 +1,7 @@
name := "inside-ci"
organization := "org.example"
val t = taskKey[Boolean]("inside-ci")
t := insideCI.value

View File

@ -0,0 +1,2 @@
# just need to verify it loads
> help