Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents

Identify custom field to use

Either choose an existing custom field from your project, or create a new one. If you already have a profile that is linked to a Jira project.

Table of Contents

...

custom field

...

, skip to the next section.

To populate create a new custom field you must first have one. Go , go to your Jira settings page, then select Issues, then Custom Fields.

...

Click 'Add custom field'.

...

Select Settings > Issues > Custom fields. In the top-right, you will see a button to create a new custom field. Click that button. Then, select your desired type of custom field. I've opted for a text field (multi-line) type.

...

Give the field a name and a description (description is optional).

...


At this point, you may also be asked to provide additional configuration depending on your custom field type.

Lastly, add your new custom field to your desired projects by ticking the checkbox beside them. Ensure that you scroll to the bottom of the page and click 'Update' to persist your project configurations.

...

...

Configuring JEMHCloud to set custom field values

Custom field values can be set on a per-project and/or per-rule basis in your JEMHCloud profile, where they are called Custom field defaults.

Go into your profile and configure it by clicking the small cog beside it . Go into the Project Mappings view. You can either configure the new Custom Field Default to be at the default project mapping resulting in your other mappings inheriting it, or you can configure it to only be in one of your non-default project mappings. I've opted to put my Custom Field Default into my default project mapping so that all of my other mappings also get it.

Click the little cog  beside the project mapping you've elected. Go into the 'Issue' view tab and click the 'Edit' button found towards the top right.Scroll down to section titled 'Custom Field Defaults' (sounds familiar... (smile)) and click the bold text that says "Velocity Context" to see the objects available at the time JEMHC processes an inbound mail. Scroll down until you see the Custom field defaults section.

Setting a static value

The simplest way to set a custom field is by passing a static text-format value. Find the desired custom field from the list. Ensure that the drop-down at the end of the row is set to Text, and enter a value to be used for this project mapping/rule.

...

Once a value has been entered, you can then select when this value should be set (issue creation, issue comment, both). Finally, submit the form to save your changes.

Setting a dynamic value

Sometimes, you may wish to set a value which is not known beforehand - for example, if the value depends upon a certain arbitrary condition being met. This can be done by setting the final drop-down to Velocity and then providing an Apache Velocity template. The final rendered output of that template will then be set as the custom field value.

JEMHCloud provides some preset template variables (references) that are available for use in the template. Click the expander labelled Velocity Context to see the what is provided at processing-time.

...

Locate your custom field. The one I created earlier on is called 'Recipients Email Addresses'. Using the objects described by the URLs under the Velocity Context I'm going to type in the following text.

Code Block
$message.to

The Velocity statement '$message' retrieves a Java object of the type IMessage which is described by the above Velocity Context. The details of the IMessage interface are shown within in the Javadoc that you can see by following the link displayed within the also linked with the Velocity Context sectionitem. The IMessage interface has a method with the signature of 'getTo()' that can be used to get the recipients' email addresses. To use this method we remove the 'get' part and the parenthesis resulting in the script you can see prior to this paragraphYou can either call the method fully, or use shorthand by just using to.

My Custom Field Default configuration now looks like the image blow. Notice how the box below the script has been set to 'Velocity' and how the box beside and to the right has been set to 'On Create'.

...

You may also want to track the incoming mailbox address , the catchemail(the catch email address), in order to use the custom field during notification, to retain a consistent sender address with what the user used initially.

...

Scroll to the bottom of the page and click 'Submit'.

...

Verify the configuration

You may already have a test case that you can easily rerun to verify the new behaviour, in which case you should skip this bit and run it. Presuming that you don't, lets set one up!

...

Code Block
MIME-Version: 1.0
Received: by 10.223.112.12 with HTTP; Sat, 18 Jun 2011 22:42:26 -0700 (PDT)
Date: Sun, 19 Jun 2011 17:42:26 +1200
Subject: Email sender inject into field test
From: "Jonathan Smitherington" <johnsmith@emaildomain.com>
To: mustCatchThisEmail@emaildomain.com
CC: anotheruser@faraway.com
Content-Type: text/plain; charset=UTF-8

This email body will go in the description of the ticket.

...

Image Added