Uploaded image for project: 'SR for Bitbucket - Development'
  1. SR for Bitbucket - Development
  2. SRBITB-427

Custom email scripts don't run Configuration script until after subject/body templates have already been evaluated

    Details

    • Type: Bug
    • Status: Done (View Workflow)
    • Priority: Medium
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 5.6.1
    • Labels:
      None
    • Sprint:
      DevTools 55
    • Critical Points:
      1

      Description

      To reproduce:

      • Set up any scripted item that sends custom emails (event handler, job, etc.)
      • In the Configuration script, add a binding to the config map.
      • Refer to that binding in the subject/body template.
      • Trigger the item.

      Expected: The bound value in config is included in the subject/body of the email.

      Actual: The item throws an exception from within the template because it can't find the binding.

      In order to permit manipulation of the MailMessage.Builder object in the Configuration script, it is constructed and fully built out before being passed into the script. This includes rendering the subject and body templates. However, users are supposed to be able to refer to the contents of the config map in those templates, and are advised to use the Configuration script to populate this map, despite the fact that it will do so too late to have any effect.

      One fix would be to populate most of the builder's fields before running the Configuration script, but leave the subject and body until afterwards when the config map is available. This would however have the downside of not allowing programmatic alteration of those fields.

      The user workarounds for the time being are either to populate config in the Condition script instead, or to set the subject and body fields programmatically in the Configuration script and not use the template fields at all.

        Attachments

          Structure

            Activity

              People

              Assignee:
              rlander Reece Lander
              Reporter:
              jchoules Joanna Choules
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Structure Helper Panel