Closed emelianrus closed 5 years ago
Hi @emelianrus
Looks like you trying to use stages of MPL in a tricky way: use the same module for different stages - depends on the purpose it could be fine or not, so I will try to explain both ways.
As you can see - the purpose of "modules" in the pipeline configuration is to provide some stage-specific configs. If module name is found in modules - it will override the basic configuration stored in the pipeline just for the module. In your case the module name is not the stage name, because you specify it during call of MPLModule
.
The easiest way for you is to manually get the required module configuration using MPL object in the pipeline - this logic will ensure module "Test-step" will use configuration for the current stage:
...
stage('Test-step-one') {
when { expression { MPLModuleEnabled() } }
steps {
MPLModule('Test-step', MPL.moduleConfig(env.STAGE_NAME))
}
}
...
But, MPL stage purpose - is to separate different stages of the pipeline (build/deploy/test for example). If you try to separate different tests and just use different configs - I could suggest to put this logic into your pipeline config/modules and execute as a part of one stage (do not use MPL "module" pipeline logic). So all your custom logic will be stored in the Test
module, that will run ExecuteTest common module with the required configs.
So my general advice - put the custom logic into module and process the configuration as you wish - use "modules" pipeline config just to put some different configurations for different stages (for example different credential ids for Build and Deploy stages).
got it, thanks
Hi, There is a problem with wrong passing variables from Jenkinsfile for example i have Jenkinsfile and i want to use different CFG for each module
and module Test-step/Test-step.groovy
and MPLPipeline with 2 stages with use the same module 'Test-step' but should pass different CFG settings
My expectation env vars in Test-step-one stage will be
and in Test-step-two will be
But it will be error, because it will try to search variables by
Test-step
name in CFG Map not by name of stageTest-step-one
orTest-step-two
https://github.com/griddynamics/mpl/blob/master/vars/MPLModule.groovy#L45 https://github.com/griddynamics/mpl/blob/master/src/com/griddynamics/devops/mpl/MPLManager.groovy#L86 Or i miss something and exist the way how to pass env vars from Jenkinsfile to container using same module without modifying files in MPL?