Closed adhikasp closed 4 years ago
Hmmm, I think it's not a good idea to export the whole CFG
, but you can get the map, stored in some variable inside CFG
, for example:
CFG.'config.a' = 1
CFG.'config.b' = 2
MPLModule('Service Deploy', CFG)
def config = CFG.config
for( it in config ) {
println("Item: ${it.key}, ${it.value}")
}
Item: a, 1
Item: b, 2
So you can get the map and iterate over it - just give the good name instead of config
, combine the good env var and write it using writeFile to workspace.
Hopefully this will help)
Or you can define env from the for loop, just use env."prefix_${it.key}" = it.value
- something like that.
Hmmm, I think it's not a good idea to export the whole CFG
Agree, I only needed subset of the CFG
anyway.
Or you can define env from the for loop, just use env."prefix_${it.key}" = it.value - something like that.
Ended up this way. Thanks for the suggestion 😄
Is there any way to export the pipeline config defined by MPL to environment variable?
I have use case to enable/disable some auxilary service (like database, redis, kafka, etc) if we want to build apps that need them in testing phase. I want the apps to be able to parse the setting from env var and connect to the right port/db/whatever.
For now, I manually define the env var for each of the config. Something like this: