Skip to content

Jelly configuration information

ronnil edited this page Feb 27, 2013 · 2 revisions

Where to do what

Assume you have a class FooBar living in java/org/jenkinsci/plugins/plugin_name/FooBar.java

Inside your class insert

@Extension 
public static final class DescriptorImpl extends Descriptor<extensionPoint> {
	public String getDisplayName(){
		return "Display name";
	}
}

to make a descriptor. Remember to add the line import hudson.model.Descriptor; ;) extensionPoint is the name of the extensionpoint you wish to add the configuration to. e.g. Builder, BuildWrapper etc.

Plugin configuration (global configuration)

Create a file in src/main/resources/org/jenkinsci/plugins/plugin_name/FooBar/global.jelly

Paste the code <j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"> </j:jelly>

into the file. Inside the j:jelly tags you can put different fields

Job configuration

Create a file in src/main/resources/org/jenkinsci/plugins/plugin_name/FooBar/config.jelly

Paste the code <j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"> </j:jelly>

into the file. Inside the j:jelly tags you can put different fields

Making form fields

Sections

You define sections with <f:section title="Title of section"></f:section>

Everything is put inside sections

Entry

Whenever you wish to create a field you define an entry <f:entry field="fieldName" title="${%Field frontend title}"></f:entry> fieldName is the internal name which is used to reference the field in the java source code title is the title displayed in the configuration form.

Basic form fields

Inside the f:entry tag is put fields. It is possible to define ones own fields. Currently these are what we work with: <f:textbox />, <f:checkbox />

You specify default values with the attribute default

Validation button

It is possible to add a validation button. Refer to https://wiki.jenkins-ci.org/display/JENKINS/Jelly+form+controls for how to do it.

Select box

It is possible to add a textbox with static or dynamic content. Refer to https://wiki.jenkins-ci.org/display/JENKINS/Jelly+form+controls

Make sure to add the line import hudson.util.ListBoxModel; ;)

Adding help text

Help files are named help-fieldName.html (or help-fieldName.jelly for dynamic content) and put inside the same folder as the other .jelly files. fieldName is the same value as defined in the f:entry tag.

###Internationalisation When writing literal string make sure to enclose it in ${% } e.g. ${%Enclosed string} this way the string will be translatable.