From 1672bf685dfdfdd6049fc4923ec2c4f1d4b6de74 Mon Sep 17 00:00:00 2001 From: Lindsay Hill Date: Tue, 25 Jul 2017 20:59:59 +1200 Subject: [PATCH 1/2] WIP ChatOps Alias --- CHANGES.md | 4 ++ actions/create_issue_workflow.meta.yaml | 49 ++++++++++++++++++++++++ actions/set_fields_on_issue.py | 36 +++++++++++++++++ actions/set_fields_on_issue.yaml | 32 ++++++++++++++++ actions/workflows/create_jira_issue.yaml | 45 ++++++++++++++++++++++ aliases/create_issue.yaml | 17 ++++++++ pack.yaml | 2 +- 7 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 actions/create_issue_workflow.meta.yaml create mode 100644 actions/set_fields_on_issue.py create mode 100644 actions/set_fields_on_issue.yaml create mode 100644 actions/workflows/create_jira_issue.yaml create mode 100644 aliases/create_issue.yaml diff --git a/CHANGES.md b/CHANGES.md index d81c620..fd0872d 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Change Log +# 0.6.0 + +- Added ChatOps alias and workflow for creating issue and assigning to user + # 0.5.1 - Added 'verify' option to disable SSL certificate verification diff --git a/actions/create_issue_workflow.meta.yaml b/actions/create_issue_workflow.meta.yaml new file mode 100644 index 0000000..371d642 --- /dev/null +++ b/actions/create_issue_workflow.meta.yaml @@ -0,0 +1,49 @@ +--- +name: create_issue +runner_type: action-chain +description: Create a new JIRA issue / ticket with fix_version and epic. +enabled: true +entry_point: workflows/create_jira_issue.yaml +parameters: + summary: + type: string + description: Issue summary. + required: true + type: + type: string + description: "Issue type. Typical issues type include Task, Story, Epic, Bug. You can also specify a custom issue type." + default: Task + required: true + description: + type: string + description: Issue description. + required: false + project: + type: string + description: destination Project in Jira. + required: false + labels: + type: array + description: List of labels for issue + required: false + fix_version: + type: string + description: Fix version to file the task under + required: false + assignee: + type: string + description: Assign this task to a person. + required: false + components: + type: array + description: List of components + required: false + priority: + type: string + description: Priority fix_version the issue. + required: false + enum: + - Blocker + - Critical + - Major + - Minor diff --git a/actions/set_fields_on_issue.py b/actions/set_fields_on_issue.py new file mode 100644 index 0000000..02e06d9 --- /dev/null +++ b/actions/set_fields_on_issue.py @@ -0,0 +1,36 @@ +from lib.base import BaseJiraAction + + +__all__ = [ + 'SetFieldsForIssueAction' +] + + +class SetFieldsForIssueAction(BaseJiraAction): + + def run(self, issue, assignee=None, status=None, + fix_version=None, labels=None, components=None): + + fields = {} + + if assignee: + fields['assignee'] = assignee + + if status: + fields['status'] = status + + if fix_version: + fields['fix_version'] = fix_version + + update_items = {} + + if labels: + update_items.update({'labels': labels}) + + if components: + update_items.update({'components': components}) + + issue = self._client.issue(issue) + issue.update(fields=fields, update=update_items) + + return (True, 'Updated issue %s' % issue) diff --git a/actions/set_fields_on_issue.yaml b/actions/set_fields_on_issue.yaml new file mode 100644 index 0000000..19ffbc8 --- /dev/null +++ b/actions/set_fields_on_issue.yaml @@ -0,0 +1,32 @@ +--- +name: set_fields_on_issue +runner_type: run-python +description: Edit JIRA issue / ticket and set fields. +enabled: true +entry_point: create_issue.py +parameters: + issue: + type: string + description: Issue ID. Usually something like PROJECT-1234. + required: true + fix_version: + type: string + description: Set the Fix Version for the issue. + required: false + status: + type: string + description: Status to set for the issue. + default: Task + required: false + components: + type: array + description: Components for the issue. + required: false + labels: + type: array + description: Labels for the issue + required: false + assignee: + type: string + required: false + description: Assignee for the issue diff --git a/actions/workflows/create_jira_issue.yaml b/actions/workflows/create_jira_issue.yaml new file mode 100644 index 0000000..36ea288 --- /dev/null +++ b/actions/workflows/create_jira_issue.yaml @@ -0,0 +1,45 @@ +version: '2.0' + +jira.create_jira_issue: + description: Create a JIRA issue. + type: direct + input: + - project + - summary + - description + - type + - labels + - components + - priority + - assignee + - fix_version + - status + + + output: + url: null + + tasks: + create_simple_issue: + action: jira.create_issue + input: + summary: <% $.summary %> + description: <% $.description %> + type: <% $.type %> + project: <% $.project %> + publish: + url: <% task(create_simple_issue).result.url %> + on-success: + - edit_issue_and_set_fields + on-error: + - fail + + edit_issue_and_set_fields: + action: jira.set_fields_on_issue + input: + issue: <% task(create_simple_issue).result.name %> + assignee: <% $.assignee %> + fix_version: <% $.fix_version %> + labels: <% $.labels %> + components: <% $.components %> + status: <% $.status %> diff --git a/aliases/create_issue.yaml b/aliases/create_issue.yaml new file mode 100644 index 0000000..18c3481 --- /dev/null +++ b/aliases/create_issue.yaml @@ -0,0 +1,17 @@ +--- +name: "create_jira_issue" +action_ref: "jira.create_issue" +description: "Create a JIRA issue." +formats: + - "create issue with summary {{summary}} description {{description}} of type {{type}}" + - "JIRA summary {{summary}} description {{description}} type {{type}} fix_version {{fix_version}}" + - "JIRA summary {{summary}} description {{description}} type {{type}} fix_version {{fix_version}} assignee {{assignee}}" + - "JIRA summary {{summary}} description {{description}} type {{type}} fix_version {{fix_version}} assignee {{assignee}} labels {{labels}}" + - "JIRA summary {{summary}} description {{description}} type {{type}} fix_version {{fix_version}} assignee {{assignee}} labels {{labels}} components {{components}}" + - "JIRA summary {{summary}} description {{description}} type {{type}} fix_version {{fix_version}} assignee {{assignee}} labels {{labels}} components {{components}} priority {{priority}}" +ack: + format: "Got it! Creating that issue for you... :book:." +result: + format: | + You are now an obedient follower of Agile/Scrum BS. + You can view your task here: {{execution.result.result.url}} diff --git a/pack.yaml b/pack.yaml index 9c126ef..fdf013a 100755 --- a/pack.yaml +++ b/pack.yaml @@ -6,6 +6,6 @@ keywords: - issues - ticket management - project management -version : 0.5.1 +version : 0.6.0 author : StackStorm, Inc. email : info@stackstorm.com From 79806382043cb8646bbc5019e0eeae3fcac595da Mon Sep 17 00:00:00 2001 From: Lindsay Hill Date: Mon, 16 Jul 2018 18:05:19 -0700 Subject: [PATCH 2/2] Disable alias by default --- aliases/create_issue.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aliases/create_issue.yaml b/aliases/create_issue.yaml index 18c3481..7b2e1ee 100644 --- a/aliases/create_issue.yaml +++ b/aliases/create_issue.yaml @@ -2,6 +2,7 @@ name: "create_jira_issue" action_ref: "jira.create_issue" description: "Create a JIRA issue." +enabled: false formats: - "create issue with summary {{summary}} description {{description}} of type {{type}}" - "JIRA summary {{summary}} description {{description}} type {{type}} fix_version {{fix_version}}" @@ -13,5 +14,5 @@ ack: format: "Got it! Creating that issue for you... :book:." result: format: | - You are now an obedient follower of Agile/Scrum BS. + You are now an obedient follower of Agile/Scrum. You can view your task here: {{execution.result.result.url}}