Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] ChatOps Alias #9

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 0.8.0

- Added ChatOps alias and workflow for creating issue and assigning to user

## 0.7.1

- Return custom fields in formatter
Expand Down
49 changes: 49 additions & 0 deletions actions/create_issue_workflow.meta.yaml
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions actions/set_fields_on_issue.py
Original file line number Diff line number Diff line change
@@ -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)
32 changes: 32 additions & 0 deletions actions/set_fields_on_issue.yaml
Original file line number Diff line number Diff line change
@@ -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
45 changes: 45 additions & 0 deletions actions/workflows/create_jira_issue.yaml
Original file line number Diff line number Diff line change
@@ -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 %>
18 changes: 18 additions & 0 deletions aliases/create_issue.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
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}}"
- "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.
You can view your task here: {{execution.result.result.url}}
2 changes: 1 addition & 1 deletion pack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ keywords:
- issues
- ticket management
- project management
version: 0.7.1
version : 0.8.0
author : StackStorm, Inc.
email : [email protected]