Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Summary

Status
colourYellow
titleSince JEMH 2.1.15

...

Static Resources can be created for global use, or scoped to a particular project.  Static Resources can be configured from the Static Resources tab within the JEMH configuration area, or within project settings when a user has project administration permission.

Image Removed

/fileJEMH Configuration

...

Project Settings

...

Creation

Within the Static Resources tab click New Static Resource:Image Removed

...

A form will appear below after pressing New Static Resource:

Image Removed
Image Added




SettingDescription
ProjectThe project the Static Resource will be scoped to
IMG WidthSets the width that will be used to render the image at runtime (pixels)
IMG HeightSets the height that will be used to render the image at runtime (pixels)
DescriptionA description of the Static Resource
Pick a fileFile picker dialogue to select the file to be uploaded as a Static Resource


After you have entered the desired settings and selected a file to be used as a Static Resource, press the Submit button. A new Static Resource will be created with the associated settings and displayed in the list of resources.

...

Images are not dynamically rendered for page load performance, to see a preview of an image click on "click to preview", the image will be downloaded and dynamically injected into the page.

...

The Static Resources tab within JEMH allows existing Static Resources to be edited.Image Removed

...

Static resources can be filtered in several ways to scope the listed resources.Image Removed

...

A list of Static Resources is shown:Image Removed

...

Editing an existing Static Resource by clicking the pencil  icon within the actions menu on the right side of a resource:

Image Removed
Image Added

The Edit Static Resource form allows you to modify the current configuration of a Static Resource. You can re-scope a resource project by modifying the Project field. Image width and height can be modified via the IMG Width and IMG Height fields. Resource description can be modified via the Description field.

You can also upload a new file which will overwrite the existing file mapped to the resource, choosing a new file via the Pick a file field and then pressing Submit. The new file will replace the existing file mapped to the resource whilst retaining the configuration options defined for the original file.

Adding Static Resources to notifications

...

From  v2.7.12 and v3.0.0 we also add a Static Resource picker so that specific attachments can be picked for specific transitions.  Given workflow is cross project, all StaticResources are pickable.Image Removed

...

By Script

Static Resources can be added to notifications by using JEMH's Template Sets system.  Velocity script is added to a custom template, defining which resources are to be attached to outbound notifications using that Template Set.

In this example we are creating a Template Set for the Issue Created event.  We will be attaching a PDF document, along with an image of a goldfish that will be embedded in the HTML body.  The outcome of this example will be that a user receives an email when the Issue Created event is fired, the email will contain some text and the goldfish image within the body and the email will also have a PDF file containing terms of service attached as an email attachment.

First create an Issue Created template, for more in-depth information on the configuration of Template Sets see: /wiki/spaces/JEMH/pages/2850840:Image Removed

...

Edit the newly created template by selecting the Edit action next to the item.  You will now be shown the template edit screen.  Enter a preview context issue key which will be used to generate template previews for use whilst designing Template Sets:Image Removed

...

To access a Static Resource you will need to know it's unique ID, this can be found on the left hand side of the Static Resource when it is listed within the Static Resources tab.Image Removed

...

The unique ID for our PDF document's Static Resource is 244, the unique ID for our goldfish image's Static Resource is 273.

Velocity methods

Method signature

Usage example

Description

renderStaticResourceImage(Project project, Integer resourceId)

$jemhUtils.renderStaticResourceImage($issue.getProjectObject(), 123)

Embeds static resource images as in-line HTML images.

renderStaticResourceImage(Integer resourceId)

$jemhUtils.renderStaticResourceImage(123)

Status
colourYellow
titlesince 2.4.1
 Same as above, however can only be used for adding resources with a global scope.

addStaticResourceAttachment(Project project, Integer resourceId)

$jemhUtils.addStaticResourceAttachment($issue.getProjectObject(), 123)

Attaches the defined Static Resource ID to the outbound notification as an email attachment.

addStaticResourceAttachment(Integer resourceId)

$jemhUtils.addStaticResourceAttachment(123)

Status
colourYellow
titlesince 2.4.1
Same as above, however can only be used for adding resources with a global scope.

If the notification event has a related issue, the current project object for an issue can be accessed via velocity using:

...

Code Block
$jemhUtils.addStaticResourceAttachment($issue.getProjectObject(), 244)
$jemhUtils.renderStaticResourceImage($issue.getProjectObject(), 273)

Append the above velocity code to the Template Set HTML section, the rendered template can be previewed using the button below the text field, when a preview context issue key has been supplied in the preview section:Image RemovedImage Removed

...

The image of the goldfish is embedded as part of the HTML template, the attached PDF document can not be previewed at this time but can be tested by sending an email using this template set. Press submit to save the changes to the Template Set.

Now that the Template Set has been configured it needs to be mapped to the JEMH Event Listener mapping for a project:Image Removed

...

To test your Static Resource Template Set, create a new issue either via a test case or an email. An Issue Created event will be triggered, the Template Set configured in the Event Listener mapping will be used to generate the notification.

The notification email will contain the goldfish image embeeded in the HTML body, the PDF document will also be attached to the received email.Image Removed

...

Adding resources to JEMH Post Function notifications

...

In this example we will configure custom content and add two resources :

  • A PDF file with resource ID 24

  • An image file with resource ID 25

Create or edit an existing JEMH Post Function and ensure that the Template selection is set to Custom Content.  Modify the Custom Content field and set the Content Markup to Velocity. 

...

The content of the post function can be previewed by supplying an example issue key in the Preview Context section.  You can preview the custom content by pressing the small blue preview button below the content field.Image RemovedImage Removed

...


Pressing the Test button in the Preview Context window will send out a test notification email to the addressed defined in the To,Cc, Bcc fields defined within the post function configuration:Image Removed

...

The final post function email should display the goldfish Static Resource image as an embedded image in the HTML body, the PDF document should also be attached to the email.Image Modified

Adding resources to Ad-Hoc notifications

...

Create an Ad-Hoc Template Set:Image Removed

...

Edit the Ad-Hoc Template Set:Image Removed

...

Edit the Ad-Hoc Template Set HTML content, in this example we have included some bold text followed by an image of a goldfish embedded via a Static Resource, we have also included a PDF document as an attachment.

The notification rendering can be previewed by supplying a preview context issue key in the preview section and then pressing the preview button below the content.Image RemovedImage Removed

...

Code Block
$jemhUtils.addStaticResourceAttachment($issue.getProjectObject(), 24)
$jemhUtils.renderStaticResourceImage($issue.getProjectObject(), 25)


Save the newly configured Ad-Hoc Template Set by pressing submit and then trigger an Ad-Hoc notification dialog from an issue, select the newly created Ad-Hoc Template Set:Image Removed

...

Select a recipient in the To: tab and then press send. The resulting email should arrive with the goldfish image Static Resourced embedded in the HTML body, and the PDF document attached to the email.Image Removed

...

Ad-Hoc Scriptlets

Note
title

Insertion of static attachments via scriptlets

Insertion of static attachments via scriptlets is currently not supported. Inserting inlined images via scriptlets is supported however.


Create a Template Set for an Ad-Hoc Scriptlet:Image Removed

...

Modify the scriptlet content to add a Static Resource as an inline image, in this example we are using a Static Resource to inline an image of a goldfish at the bottom of the scriptlet.

The rendering of the scriptlet can be previewed by entering an issue key in the preview section and then pressing the preview button below the scriptlet content field.Image RemovedImage Removed

...

Code Block
$jemhUtils.renderStaticResourceImage($issue.getProjectObject(), 27)

...

Insert the Scriptlet into an Ad-Hoc notification by triggering the Ad-Hoc notification dialog and then using the insert menu:Image RemovedImage RemovedImage Removed

...

Related Articles

Filter by label (Content by label)
showLabelsfalse
max5
showSpacefalse
cqllabel in ( "attachments" , "notifications" , "post-function" , "velocity" ) and type = "page" and space = currentSpace ( )