Git Product home page Git Product logo

structs-plugin's Introduction

Structs plugin

Library plugin for DSL plugins that need concise names for Jenkins extensions

Overview

Jenkins has many DSL like plugins that require having short concise names for implementations of the extension points and other Jenkins objects. For example, Job DSL Plugin refers to each SCM extension by its short name. The same goes for pipeline plugin.

It benefits users that these DSL plugins use consistent names. This plugin, together with the @Symbol annotation, allow plugin developers to name their extension and have all the DSL plugins recognize them.

Usage for developers creating any plugins

To allow all the DSL plugins to refer to your extensions by the same name, put @Symbol annotation along side your @Extension. The symbol name must be a valid Java identifier, and it should be short and concise. To keep the symbol name short, it needs to be only unique within the extension point. For example, GitSCM and GitToolInstaller should both have a symbol name git, because they are from different extension points. For compatibility reasons with DSL plugins that predates the structs plugin, some extensions may have legacy names that do not follow this convention.

public class GitSCM {
   ...

   @Extension @Symbol("git")
   public static class DescriptorImpl extends SCMDescriptor {
      ...
   }
}

If you are targeting 1.x version of Jenkins, you must also add the following dependency to your plugin POM:

    <dependency>
        <groupId>org.jenkins-ci.plugins</groupId>
        <artifactId>structs</artifactId>
        <version>1.2</version>
    </dependency>

Usage for DSL plugin developers

Look up an extension by its symbol:

@Extension @Symbol("foo")
public class FooGlobalConfiguration extends GlobalConfiguration {
   ...
}

// this yields the FooGlobalConfiguration instance
SymbolLookup.get().find(GlobalConfiguration.class, "foo")

Construct a Describable object from a key/value pairs, much like how Structured Form Submission does it via @DataBoundConstructor:

new DescribableModel(Mailer.class).instantiate(
        Collections.singletonMap("recipients", "[email protected]"))

Version history

Please refer to the Changelog

structs-plugin's People

Contributors

abayer avatar based2 avatar basil avatar batmat avatar car-roll avatar daspilker avatar dependabot[bot] avatar dwnusbaum avatar jglick avatar kohsuke avatar mramonleon avatar oleg-nenashev avatar res0nance avatar stephenc avatar svanoort avatar vlatombe avatar zbynek avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.