Pipeline - how to have a global config that's accessible from every step?

35 views
Skip to first unread message

bbyjenkns

unread,
Aug 11, 2017, 11:45:31 AM8/11/17
to Jenkins Users
I'm putting together a jenkins global library and am struggling with creating a true global configuration. 

My Jenkinsfiles are pretty flat, and mostly just load the global library, set some build specific configuration values, and then calls a step that contains most of the build logic (calls other steps to run the build/test/install). What I was hoping I could do is have a separate properties file that I can load that contains a bunch of default global configuration values, and have it be accessible from all steps. Per the doc, I'm supposed to be able to create a class to hold this global config, but I have to actually pass this class into each step to make it available, which is really ugly. 

I'm thinking the best approach is to create a config step that reads the file and loads the config, write that config to a file and stash it, then have a utility method that reads the stashed config in any steps that need to access it. Though, I also really don't like this option either. 

Is there a good way in pipeline to make a globally accessible config that I'm missing?

Steffen Elste

unread,
Aug 17, 2017, 3:18:55 AM8/17/17
to Jenkins Users
Hi,
You might want to have a closer look at the Config File Provider Plugin - plays nicely with Pipelines and allows for various types of configuration files to be configured (globally).
Cheers,

Steffen
Reply all
Reply to author
Forward
0 new messages