Obviously, we won’t help with your jenkins part.
To reduce verbosity (as I don’t think that is the subject at hand), let’s start with this code:
class Sample extends Simulation {
private val httpProtocol = http
.baseUrl("https://sample.com")
val scnLaunchApp = scenario("LaunchApp").exec(
// ...
)
val scniosDeviceApps = scenario("iosDeviceApps").exec(
// ...
)
setUp(
scnLaunchApp.inject(atOnceUsers(1)),
scniosDeviceApps.inject(atOnceUsers(1)),
).protocols(httpProtocol)
}
Do you know that setUp
may take a List[PopulationBuilder]
as arguments?
val injections = List(
scnLaunchApp.inject(atOnceUsers(1)),
scniosDeviceApps.inject(atOnceUsers(1)),
)
setUp(injections).protocols(httpProtocol)
Do you know that you can build a list of elements that are optional?
val sample = List(
Some(1),
None,
Some(2),
None,
None,
Some(3)
)
// val sample: List[Option[Int]] = List(Some(1), None, Some(2), None, None, Some(3))
Then, you can flatten
it
sample.flatten
// res: List[Int] = List(1, 2, 3)
In another hand, you can get an option for an environment variable with sys.env.get("ENV_NAME")
or an option of system property with sys.props.get("prop.name")
.
So, you can write something like:
val injections = List(
sys.props.get("launchApp").filter(_ == "true").map(_ => scnLaunchApp.inject(atOnceUsers(1))),
sys.props.get("iosDeviceApps").filter(_ == "true").map(_ => scniosDeviceApps.inject(atOnceUsers(1))),
).flatten
setUp(injections).protocols(httpProtocol)
To achieve what you want.
Is that clear?
I (really do) hope that helps.
Cheers!