-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion for configuration #21
Comments
Hello @digulla, Happy to see you thinking about the improvements for MPL configuration) Unfortunately it's quite hard to understand the idea without a code, but seems like you proposing for some huge interface changes. Thank you |
I've created a gist with unit tests: https://gist.github.com/digulla/15a55d8a5cefb2bda1e2da1fb6dae4f7 I'd like to first discuss this code and then start with a fork. |
Thank you @digulla , we will check it shortly. |
Hi @digulla, I checked the source code and from the tests I see, that the configuration becomes quite bulky. Also it's hard to predict where this will go. I think it just will move a part of the module logic to the configs, that seems not good... Thank you |
My goals are:
It has to be somewhere. With your design, all plugins accessing this config option must use the same pattern to read it. Specifically, the default value must be the same everywhere or weird things will happen ("hey, why is it doing this here and that there????"). In my design, the default config does it for everyone, so everyone can simply use I think we should talk about my design goals. I think they are worth the effort because they help to catch a lot of bugs. |
Yeah, agree. We just need to compare the differences of approaches, the interface changes, required efforts to implement and backward compatibility to make some other decisions. |
I ran into an interesting question while trying to implement my idea. Where to put the default config?
I don't like option 1 very much. Only if we're very desperate. With option 2, I expect name collisions when we merge the override configs (configs in the projects). With option 3, a lot of code would have to be changed. Also, CPS might cause problems. Lastly, people might try to put state into those classes and we would have to decide how to handle that. Option 4 sounds doable but I would like to have the config and the code in a single file. Otherwise, we might set a precedent and end up with tons of file fragments. That aside, you currently have some logic to prevent endless loops when a module calls it's parent. With option 2 and 3, the parent code could be passed to the override module as closure. |
Probably it will be suitable to create |
I would really like to collect all config options before starting to build. Maybe a solution would be to use a different approach for the pipeline: Instead of using explicit steps, we could create the steps dynamically (see https://stackoverflow.com/questions/42837066/can-i-create-dynamically-stages-in-a-jenkins-pipeline). That way, we could collect all the modules which are part of the build beforehand. With a flag, we could disable executing the "build code" module. Then we run all the modules to collect all config options. With that, we can merge the overrides for the current build, log the result, enable execution again, disable the code in The other solution would be to run all modules that we can find but that would run Or is there a way to discover the stages in a Jenkinsfile while running it? Isn't Jenkins showing all stages before it starts executing the first one? |
Hi @digulla You can use any pipelines you want - default MPLPipeline is just to show a simple example pipeline. Sorry, but it's still overcomplicated to just understand what you saying without some logic to play with... I'm usually just trying one way, that if something is not working perfect enough - another and so on. There for sure some ways (at least you can use vars steps and going deep into the jenkins objects to locate what you need) - but be careful, noone likes too much complicated logic... |
This is another approach to enhance the config (similar to #10).
I would suggest a "default config" object which contains all possible config keys and defaults.
Modules must have a method to add to this default config. Adding the same "path" twice is an error but it should be possible to check for an existing path (so two modules can cooperate and still be optional).
This way, modules don't need code like
because 'Maven 3' will be the default value. Reading unknown keys should throw an exception (-> typo in library)
The step which parses the project's config options from the should throw exceptions for unknown keys/paths to catch typos.
After merging the project and default config, the result should be logged in Jenkins to allow to find mistakes.
I'm also not fond of the
CFG.'xxx.yyy'
syntax. With the default config as path supplier, it should be possible to implement a nested config using nestedMap
s which would then allow to pass inner maps around so the code would become independent of the path.In my builds, I'm calling Maven several times (build with unit tests, site, deploy without tests). Using nested configs, I can create a shared Maven config (default JDK & Maven tool) but I can also tweak the options passed to each individual Maven invocation like additional profiles to activate or system properties. As an example, I can:
to get
mvn [...] clean install foo sonar:sonar
as command line or I canto add
-Dfoo=[...]
to every Maven invocation.My current code depends on a hand-written config builder class for each nested config object. That way, I can support things like
addAfter()
. I'm looking into ways to change this so modules can easily define their default config.The text was updated successfully, but these errors were encountered: