griddynamics / mpl

[IT-36925] Jenkins Shared Modular Pipeline Library
https://blog.griddynamics.com/developing-a-modular-pipeline-library-to-improve-devops-collaboration/
Apache License 2.0
156 stars 97 forks source link

How to Parameterized Build like origin pipeline keyword [parameters] #63

Closed Cheava closed 4 years ago

Cheava commented 4 years ago

This project is great, and I want to build our company ci architure based on it. Because of multi environment and sub-project in our company, so I'm wondering how to parameterized build as title said. Thank you.

sparshev commented 4 years ago

Hi @Cheava ,

MPL allows to configure the pipeline through MPLPipelineConfig and further altering/adjusting this configs through CFG passed to the modules and OUT from the modules. To use parameters of the build itself - you can use the common jenkins global variables allowed in the same MPLPipelineConfig

For example, when you creating the pipeline job - you can set the job build parameter with name BUILD_PARAM and use it in the Jenkinsfile / Pipeline Script:

...
MPLPipeline {
    my_param = params.BUILD_PARAM
    modules.Build.my_env = env.USER
}

Then in the module you can use this global my_param as CFG.my_param just like the same in Build module(s) the CFG.my_env.

Of course you can use the same env/params directly in your NestedPipeline during providing defaults/mandatory configs to MPLPipelineConfig.

sparshev commented 4 years ago

@Cheava , I see no updates for almost a week - so I think the question was answered. Please reopen it if that's wrong.

Cheava commented 4 years ago

The question has been solved. Thank you~