Clones an Issue and Links
Use this listener to clone the current issue to a new one and create a link between the two. You can specify which fields are being copied, either all fields, no fields, or specific fields, from the source issue to the new one.
For example, you might want to:
- Clone an issue and specific fields to a Security Issue Tracker project when a user updates a CVE Level custom select list field to Critical.
- Clone an issue and all fields to a new project so you can easily create multiple similar linked issues.
This listener allows you to copy both custom fields and system fields. You can also specify which user the issue is cloned on behalf of; this sets the Creator and Reporter fields.
When cloning an issue from one project to another, there may be times when a field is required in the target project but not required in the project of the issue being cloned, and therefore that field may be empty in the issue being cloned. In such a situation the issue is still cloned and the field will remain empty until you go into the target issue and edit it manually.
Run this listener
Additional issue actions
Control of cloning links
Both outward and inward links are copied. So if issue A depends on issue B, after cloning to issue C then issue C will also depend on issue B. And similarly if issue B was depended on by issue A.
checkLink in the Additional Issue Actions field. The callback will be called for every link found and should return true or false. This is passed one parameter, the IssueLink object. For example, to disable the cloning of links altogether use this code:checkLink = {link -> false};checkLink = {link -> link.issueLinkType.name != "Clones"}Control of cloning attachments
checkAttachment = {attachment -> false}checkAttachment = {attachment -> attachment.authorKey == 'jbloggs'}After Create actions
There are some actions that can take place only after the creation of the issue (add watcher, create issue links etc), in this case you can apply additional actions after the creation of the new issue, using the doAfterCreate callback (closure).
For example, add watchers to the new issue:
doAfterCreate = {
issue.addWatcher('anuser')
}Another use of it could be, linking the new issue to another one. For example create a 'duplicates' issue link between the new issue and an issue with key JRA-24:
doAfterCreate = {
def issueToLinkTo = Issues.getByKey("SSPA-1")
issue.link('duplicates', issueToLinkTo)
}issueoutside the doAfterCreate closure is not yet created and trying to access it will result to an error (the issue.getKey() will throw a NullPointerException). On the other hand the issueinside the doAfterCreate callback is created and exists (therefore the issue.getKey() will return the key of the new issue).