| 1 | [[PageOutline(2-5,Contents,pullout)]] |
| 2 | |
| 3 | = WorkflowNotificationPlugin = |
| 4 | |
| 5 | == Description == |
| 6 | |
| 7 | WorkflowNotificationPlugin enables flexible configuration of email |
| 8 | notifications tied to ticket workflow changes. |
| 9 | |
| 10 | Administrators can configure any number of distinct email |
| 11 | notifications to be sent out when a workflow operation occurs on a |
| 12 | ticket. Each email notification is specifically attached to one or |
| 13 | more workflow operations, so (for example) separate emails can be sent |
| 14 | out when a ticket is accepted, reassigned, resolved, reopened, or |
| 15 | marked "in QA". |
| 16 | |
| 17 | Each email notification's subject, body, and recipients are fully |
| 18 | configurable by administrators, as Genshi templates which have access |
| 19 | to the ticket's data, the comment (if any) that was left on the |
| 20 | ticket, and the author of the change. Therefore notifications can be |
| 21 | very flexible: some notifications can be sent to the ticket's |
| 22 | reporter, others to its owner or CC list, others to the current |
| 23 | updater, and others to hard-coded lists of users. |
| 24 | |
| 25 | The notification emails sent by this plugin respect trac's ALWAYS_CC |
| 26 | and ALWAYS_BCC settings. |
| 27 | |
| 28 | The notification emails sent by this plugin are orthogonal to trac's |
| 29 | ALWAYS_NOTIFY_UPDATER, ALWAYS_NOTIFY_OWNER, and ALWAYS_NOTIFY_REPORTER |
| 30 | settings; Trac's built-in email notifications will be sent according |
| 31 | to those settings, independent of this plugin's emails. |
| 32 | |
| 33 | == Installation == |
| 34 | |
| 35 | Install the plugin's source code: |
| 36 | {{{ |
| 37 | $ easy_install trac-WorkflowNotificationPlugin |
| 38 | }}} |
| 39 | |
| 40 | Enable its components in trac.ini: |
| 41 | {{{ |
| 42 | [components] |
| 43 | workflow_notification.* = enabled |
| 44 | }}} |
| 45 | |
| 46 | Add its component to your list of workflow providers, after all other |
| 47 | workflow providers; for example: |
| 48 | {{{ |
| 49 | [ticket] |
| 50 | workflow = ConfigurableTicketWorkflow, TicketWorkflowNotifier |
| 51 | }}} |
| 52 | |
| 53 | Now you just need to configure some notifications; see below for |
| 54 | details and examples. |
| 55 | |
| 56 | |
| 57 | |
| 58 | == Bugs/Feature Requests == |
| 59 | |
| 60 | Existing bugs and feature requests for WorkflowNotificationPlugin are |
| 61 | [report:9?COMPONENT=WorkflowNotificationPlugin here]. |
| 62 | |
| 63 | If you have any issues, create a |
| 64 | [http://trac-hacks.org/newticket?component=WorkflowNotificationPlugin&owner=ejucovy new ticket]. |
| 65 | |
| 66 | == Download == |
| 67 | |
| 68 | Download the zipped source from [download:workflownotificationplugin here]. |
| 69 | |
| 70 | == Source == |
| 71 | |
| 72 | You can check out WorkflowNotificationPlugin from [http://trac-hacks.org/svn/workflownotificationplugin here] using Subversion, or [source:workflownotificationplugin browse the source] with Trac. |
| 73 | |
| 74 | == Example == |
| 75 | |
| 76 | == Configuration == |
| 77 | |
| 78 | Configure one or more notification emails attached to workflow events |
| 79 | using a `ticket-workflow-notifications` section in `trac.ini`. |
| 80 | |
| 81 | Within this section, each entry is a notification email that may be |
| 82 | sent out for a ticket. Here is an example: |
| 83 | {{{ |
| 84 | [ticket-workflow-notifications] |
| 85 | notify_reporter_when_accepted = accept |
| 86 | notify_reporter_when_accepted.body = Hi $ticket.reporter, '$ticket.summary' has been accepted by $change.author. Its status is now $ticket.status.\n\n{% if change.comment %}$change.author said:\n\n$change.comment{% end %}-----\nTicket URL: $link\n$project.name <${project.url or abs_href()}>\n$project.descr |
| 87 | notify_reporter_when_accepted.recipients = $ticket.reporter, trac-admin@hostname.com, trac_user |
| 88 | notify_reporter_when_accepted.subject = '$ticket.summary' is now accepted |
| 89 | }}} |
| 90 | |
| 91 | The first line in this example defines the |
| 92 | `notify_reporter_when_accepted` rule. The value in this line defines |
| 93 | one or more workflow actions that will trigger this notification: in |
| 94 | this case, the notification will be triggered when the "accept" action |
| 95 | occurs for any ticket. (This action is defined by the default |
| 96 | configuration of Trac's built in ticket workflow engine; however, any |
| 97 | action that is defined by the configuration of your installed |
| 98 | ITicketActionControllers may be used.) |
| 99 | |
| 100 | We could also define a notification to occur on multiple workflow |
| 101 | actions, using a comma separated list of workflow actions: |
| 102 | {{{ |
| 103 | notify_owner_changed = accept, reassign |
| 104 | }}} |
| 105 | |
| 106 | Multiple independent notifications can be configured for the same |
| 107 | workflow action; in the above examples, both the |
| 108 | `notify_owner_changed` and the `notify_reported_when_accepted` rules |
| 109 | will be triggered when the "accept" action occurs. |
| 110 | |
| 111 | The following lines define the email subject, body, and recipients for |
| 112 | a particular notification. These are all Genshi Text Templates that |
| 113 | will be rendered with a context that includes the ticket (in its |
| 114 | current state AFTER the workflow action has been applied); the author |
| 115 | and comment of the current change, if any; a link to the ticket as |
| 116 | `$link`; and the project. |
| 117 | |
| 118 | All of these must be defined for each notification; the plugin will |
| 119 | raise errors at runtime if a notification is missing any of the |
| 120 | `.subject`, `.body` or `.recipients` definitions. |
| 121 | |
| 122 | The `.recipients` definition should be a Genshi template that renders |
| 123 | to a comma separated list of email addresses and/or usernames known to |
| 124 | Trac. In the above example we combine a dynamic variable based on the |
| 125 | ticket's current state, a username known to Trac, and a hard coded |
| 126 | email address: |
| 127 | {{{ |
| 128 | notify_reporter_when_accepted.recipients = $ticket.reporter, trac-admin@hostname.com, trac_user |
| 129 | }}} |
| 130 | |
| 131 | ==== Notifications for new tickets ==== |
| 132 | |
| 133 | Most notifications are configured to refer to one or more workflow actions, |
| 134 | like "accept", "leave", "reassign", "resolve", etc. |
| 135 | |
| 136 | You can also configure notifications to be triggered when a ticket is |
| 137 | newly created. To do this, use the special workflow action `@created` |
| 138 | like so: |
| 139 | |
| 140 | {{{ |
| 141 | [ticket-workflow-notifications] |
| 142 | new_ticket = @created |
| 143 | new_ticket.body = New ticket $ticket.summary has been created |
| 144 | new_ticket.recipients = $ticket.owner |
| 145 | new_ticket.subject = New ticket created |
| 146 | }}} |
| 147 | |
| 148 | ==== Notifications for all actions ==== |
| 149 | |
| 150 | You can also set the special value `*` for a notification, which means |
| 151 | it will be triggered on every workflow action including ticket creation: |
| 152 | |
| 153 | {{{ |
| 154 | [ticket-workflow-notifications] |
| 155 | ticket_changed = * |
| 156 | ticket_changed.body = View the ticket here: $link |
| 157 | ticket_changed.recipients = watchful_user, another_watchful_user |
| 158 | ticket_changed.subject = Ticket $ticket.id has changed! |
| 159 | }}} |
| 160 | |
| 161 | ==== Notifications for the when no action has occurred ==== |
| 162 | |
| 163 | A workflow action always occurs when a ticket is changed, even if the user |
| 164 | doesn't explicitly select a workflow action! In the standard Trac configuration, |
| 165 | the default action is "leave". So you could set up a notification like so: |
| 166 | |
| 167 | {{{ |
| 168 | same_status = leave |
| 169 | same_status.body = View the ticket here: $link |
| 170 | same_status.recipients = watchful_user, another_watchful_user |
| 171 | same_status.subject = Ticket $ticket.id has been edited! |
| 172 | }}} |
| 173 | |
| 174 | |
| 175 | == Recent Changes == |
| 176 | |
| 177 | [[ChangeLog(workflownotificationplugin, 3)]] |
| 178 | |
| 179 | == Author/Contributors == |
| 180 | |
| 181 | '''Author:''' [wiki:ejucovy] [[BR]] |
| 182 | '''Maintainer:''' [wiki:ejucovy] [[BR]] |
| 183 | '''Contributors:''' |