Closed maxime-michel closed 3 years ago
Hi @maxime-michel , as far I get it - you worrying about the pipeline configuration? So the MPLPipeline
is just an example - and for sure you can copy it and create your pipeline definition with the configuration you want. I'm quite sure you even can create a dynamic trigger definition (use cron or whatever trigger you want) by adding a custom step in vars definitions.
Please check the custom pipeline example here to get some references in mpl-nested/vars/NestedPipeline.groovy
: https://github.com/griddynamics/mpl/wiki#examples
Hi @sparshev,
Thanks for your answer. I am already working with a nested MPL pipeline, which I defined here: https://github.com/magnolia-cms/test-mpl-nested-library/blob/master/vars/NestedPipeline.groovy
And while I can successfully configure MPL modules or individual stages (such as the Maven version used for the build shown in the example), my problem is that cron
is a property that is outside of the scope of MPL modules:
pipeline {
agent any
triggers {
cron('H */4 * * 1-5')
}
stages {
stage('Example') {
steps {
echo 'Hello World'
}
}
}
}
Using cron(MPL.cron)
simply blows up with: hudson.remoting.ProxyException: groovy.lang.MissingPropertyException: No such property: cron for class: com.griddynamics.devops.mpl.MPLManager
Whereas it would work with MPL.agentLabel
thanks to the following getter in MPLManager
: https://github.com/griddynamics/mpl/blob/master/src/com/griddynamics/devops/mpl/MPLManager.groovy#L87
The only way to support my use case would be that getCron()
gets defined in MPLManager
, because I don't think I'm supposed to write my own MPLManager
. Or am I wrong?
So, I think what you need - is to just use the configuration, because you know - modifying of the core MPL for each small parameter is quite bad way to manage the configuration. The getAgentLabel()
was introduced due to it's common nature for every pipeline (which uses labels).
For anything else I would recommend to use cron(MPL.config.cron)
in your case - just access the config directly, it's marked as private but accessible in groovy. But overall I think it's possible to add getConfig()
method to allow proper access via MPLConfig
to the whole pipeline configuration. And it will work well just as usual MPL.config.'property.path'
. So for now please use just MPL.config
and I will think about it more and prepare the change to simplify our life)
Thank you! That's perfectly acceptable for me, I just didn't quite see how to pull this out. I'll close this issue since the API you have in mind has little to do with what's been described here, OK?
Ok, created a new ticket to implement the discussed interface.
In our setup, some pipelines require a custom cron:
We already have a setup in which no cron is defined by default, and some project pipelines can override that. However, I would like to replicate this with MPL, because MPL brings a lot more flexibility than the templates we are currently working with.
Do I get this right that because that property is top-level such as
agent_label
, then a getter would be needed inMPLManager
? What are you thoughts on adding it?