Very basic global config question

76 views
Skip to first unread message

Christopher Mead

unread,
Jun 3, 2021, 1:52:45 PM6/3/21
to Jenkins Developers
Hi,

I  followed the following excellent tutorial to create a Jenkins plugin: https://www.jenkins.io/doc/developer/tutorial/

This covered enough for me to create a useful plugin for internal use at work. However, it makes no mention of what to do to add "global configuration" that would apply for all instances of your plugin in jobs. In other words, I'd like to understand enough to add a single string of configuration data that would appear under "Manage Jenkins" > "Configure System" and apply to every instance of the plugin in jobs.

I have been poking through some open source plugin repos and finding myself very lost.  I know that undoubtedly I need to create a jelly file, somehow get it into the global config page and read my string from it, but I can't seem to piece together the basics for doing this.

Any help would be appreciated.

Thanks,

Chris 

Daniel Beck

unread,
Jun 3, 2021, 2:54:02 PM6/3/21
to Jenkins Developers


> On 3. Jun 2021, at 19:18, Christopher Mead <mead.rob...@gmail.com> wrote:
>
> This covered enough for me to create a useful plugin for internal use at work. However, it makes no mention of what to do to add "global configuration" that would apply for all instances of your plugin in jobs. In other words, I'd like to understand enough to add a single string of configuration data that would appear under "Manage Jenkins" > "Configure System" and apply to every instance of the plugin in jobs.

There's a project archetype for this called 'global-configuration', see https://github.com/jenkinsci/archetypes -- see the README how to create a project from this, or just steal from https://github.com/jenkinsci/archetypes/tree/master/global-configuration/src/main/resources/archetype-resources/src/main

All you need in addition is to look up the instance of your global config using ExtensionList#lookupSingleton from your build step (or whatever else you create), and retrieve the current configuration from it.

Christopher Mead

unread,
Jun 3, 2021, 4:10:28 PM6/3/21
to Jenkins Developers
Thank you very much, Daniel.  That is exactly what I needed!
Reply all
Reply to author
Forward
Message has been deleted
0 new messages