Link a Jira ticket based on the url custom field
Description
This documentation will show you how you can link a Jira work item based on the value of a URL custom field.
Instructions
Please add the following snippet to the JQL expression in the Link issues to the current issue post function configuration.
{% set url_parts = issue.fields.customfield_xxxx.split('/') %}
issuekey = {{ url_parts[url_parts.length - 1] }}Explanation
Replace
xxxxwith the ID of the URL custom field.
The value of the URL field will be in the following format:
https://YourInstaneName.atlassian.net/browse/<Jira issue Key>
The expected value for the JQL expression is a valid Jira issue key e.g ABC-123.
split('/')Splits the string contained in
customfield_xxxxinto an array of substrings based on the delimiter'/'.The
split('/')method would result in the array:["https:", "", "YourInstaneName.atlassian.net", "ABC-123"].
length - 1The
lengthproperty of an array in Nunjucks returns the number of elements in the array.length - 1gives the index of the last element in the array e.gABC-123.
url_parts[url_parts.length - 1]This expression accesses the last element of the
url_partsarray.