diff --git a/CHANGES.md b/CHANGES.md index 73fd148..0ecc0ff 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,12 @@ # Change Log +## 3.1.0 +- Add new feature to ``jira.get_issue`` to allow for stripping of Jinja templating artifacts from resulting output. (Removes instances of {{ }} from results.) + + Example: You pull a jira with ``code`` block in a comment or the description. To the API that shows up as {{ code }} which is jinja Templating and will cause + issues when trying to use that output anywhere else in a workflow as it cannot find the `code` variable in the context. + + ## 3.0.1 - Fixed bug with `update_dashboard` action sending the wrong payload. diff --git a/actions/get_issue.py b/actions/get_issue.py index 92b61d6..6dcbedb 100644 --- a/actions/get_issue.py +++ b/actions/get_issue.py @@ -9,7 +9,7 @@ class GetJiraIssueAction(BaseJiraAction): def run(self, issue_key, include_comments=False, include_attachments=False, include_customfields=False, include_components=False, include_subtasks=False, - include_links=False): + include_links=False, sanitize_formatting=False): issue = self._client.issue(issue_key) result = to_issue_dict(issue=issue, include_comments=include_comments, include_attachments=include_attachments, @@ -17,4 +17,15 @@ def run(self, issue_key, include_comments=False, include_attachments=False, include_components=include_components, include_subtasks=include_subtasks, include_links=include_links) - return result + + def strip_braces(data): + if isinstance(data, dict): + return {k: strip_braces(v) for k, v in data.items()} + elif isinstance(data, list): + return [strip_braces(element) for element in data] + elif isinstance(data, str): + return data.replace("{{", "").replace("}}", "") + else: + return data + + return strip_braces(result) if sanitize_formatting else result diff --git a/actions/get_issue.yaml b/actions/get_issue.yaml index e83d1ce..71be829 100644 --- a/actions/get_issue.yaml +++ b/actions/get_issue.yaml @@ -39,3 +39,8 @@ parameters: description: True to include linked issues. required: true default: false + sanitize_formatting: + type: boolean + description: When set to true removes jinja template artifacts. + required: true + default: false diff --git a/pack.yaml b/pack.yaml index 5801e07..e7a516c 100644 --- a/pack.yaml +++ b/pack.yaml @@ -6,7 +6,7 @@ keywords: - issues - ticket management - project management -version: 3.0.1 +version: 3.1.0 python_versions: - "3" author: StackStorm, Inc.