jira: Add JQL search command.
This commit is contained in:
parent
a46dae37f5
commit
a9268a1947
|
@ -49,6 +49,25 @@ Jira Bot:
|
|||
|
||||
---
|
||||
|
||||
### jql
|
||||
|
||||
`jql` takes in a jql search string and returns matching issues. For example,
|
||||
|
||||
you:
|
||||
|
||||
> @**Jira Bot** jql "issuetype = Engagement ORDER BY created DESC"
|
||||
|
||||
Jira Bot:
|
||||
|
||||
> **Search results for "issuetype = vulnerability ORDER BY created DESC"**
|
||||
>
|
||||
> *Found 53 results*
|
||||
>
|
||||
> - ***BOTS-1:*** External Website Test **[In Progress]**
|
||||
> - ***BOTS-3:*** Network Vulnerability Scan **[Draft]**
|
||||
|
||||
---
|
||||
|
||||
### create
|
||||
|
||||
`create` creates an issue using its
|
||||
|
|
|
@ -28,6 +28,7 @@ EDIT_REGEX = re.compile(
|
|||
'$'
|
||||
)
|
||||
SEARCH_REGEX = re.compile('search "(?P<search_term>.+)"$')
|
||||
JQL_REGEX = re.compile('jql "(?P<jql_query>.+)"$')
|
||||
HELP_REGEX = re.compile('help$')
|
||||
|
||||
HELP_RESPONSE = '''
|
||||
|
@ -70,6 +71,23 @@ Jira Bot:
|
|||
|
||||
---
|
||||
|
||||
**jql**
|
||||
|
||||
`jql` takes in a jql search string and returns matching issues. For example,
|
||||
|
||||
you:
|
||||
|
||||
> @**Jira Bot** jql "issuetype = Engagement ORDER BY created DESC"
|
||||
|
||||
Jira Bot:
|
||||
|
||||
> **Search results for *"issuetype = Engagement ORDER BY created DESC"*:**
|
||||
>
|
||||
> - ***BOTS-1:*** External Website Test **[In Progress]**
|
||||
> - ***BOTS-3:*** Network Vulnerability Scan **[Draft]**
|
||||
|
||||
---
|
||||
|
||||
**create**
|
||||
|
||||
`create` creates an issue using its
|
||||
|
@ -188,6 +206,7 @@ class JiraHandler:
|
|||
create_match = CREATE_REGEX.match(content)
|
||||
edit_match = EDIT_REGEX.match(content)
|
||||
search_match = SEARCH_REGEX.match(content)
|
||||
jql_match = JQL_REGEX.match(content)
|
||||
help_match = HELP_REGEX.match(content)
|
||||
|
||||
if get_match:
|
||||
|
@ -277,6 +296,10 @@ class JiraHandler:
|
|||
search_term = search_match.group('search_term')
|
||||
search_results = self.jql_search("summary ~ {}".format(search_term))
|
||||
response = '**Search results for "{}"**\n\n{}'.format(search_term, search_results)
|
||||
elif jql_match:
|
||||
jql_query = jql_match.group('jql_query')
|
||||
search_results = self.jql_search(jql_query)
|
||||
response = '**Search results for "{}"**\n\n{}'.format(jql_query, search_results)
|
||||
elif help_match:
|
||||
response = HELP_RESPONSE
|
||||
else:
|
||||
|
|
|
@ -80,6 +80,23 @@ Jira Bot:
|
|||
|
||||
---
|
||||
|
||||
**jql**
|
||||
|
||||
`jql` takes in a jql search string and returns matching issues. For example,
|
||||
|
||||
you:
|
||||
|
||||
> @**Jira Bot** jql "issuetype = Engagement ORDER BY created DESC"
|
||||
|
||||
Jira Bot:
|
||||
|
||||
> **Search results for *"issuetype = Engagement ORDER BY created DESC"*:**
|
||||
>
|
||||
> - ***BOTS-1:*** External Website Test **[In Progress]**
|
||||
> - ***BOTS-3:*** Network Vulnerability Scan **[Draft]**
|
||||
|
||||
---
|
||||
|
||||
**create**
|
||||
|
||||
`create` creates an issue using its
|
||||
|
@ -137,6 +154,7 @@ Jira Bot:
|
|||
MOCK_SEARCH_RESPONSE = '**Search results for "TEST"**\n\n*Found 2 results*\n\n\n - TEST-1: [summary test 1](https://example.atlassian.net/browse/TEST-1) **[To Do]**\n - TEST-2: [summary test 2](https://example.atlassian.net/browse/TEST-2) **[To Do]**'
|
||||
MOCK_SEARCH_RESPONSE_URL = '**Search results for "TEST"**\n\n*Found 2 results*\n\n\n - TEST-1: [summary test 1](http://test.com/browse/TEST-1) **[To Do]**\n - TEST-2: [summary test 2](http://test.com/browse/TEST-2) **[To Do]**'
|
||||
MOCK_SEARCH_RESPONSE_SCHEME = '**Search results for "TEST"**\n\n*Found 2 results*\n\n\n - TEST-1: [summary test 1](http://example.atlassian.net/browse/TEST-1) **[To Do]**\n - TEST-2: [summary test 2](http://example.atlassian.net/browse/TEST-2) **[To Do]**'
|
||||
MOCK_JQL_RESPONSE = '**Search results for "summary ~ TEST"**\n\n*Found 2 results*\n\n\n - TEST-1: [summary test 1](https://example.atlassian.net/browse/TEST-1) **[To Do]**\n - TEST-2: [summary test 2](https://example.atlassian.net/browse/TEST-2) **[To Do]**'
|
||||
|
||||
def _test_invalid_config(self, invalid_config, error_message) -> None:
|
||||
with self.mock_config_info(invalid_config), \
|
||||
|
@ -212,6 +230,11 @@ Jira Bot:
|
|||
self.mock_http_conversation('test_search'):
|
||||
self.verify_reply('search "TEST"', self.MOCK_SEARCH_RESPONSE)
|
||||
|
||||
def test_jql(self) -> None:
|
||||
with self.mock_config_info(self.MOCK_CONFIG_INFO), \
|
||||
self.mock_http_conversation('test_search'):
|
||||
self.verify_reply('jql "summary ~ TEST"', self.MOCK_JQL_RESPONSE)
|
||||
|
||||
def test_search_url(self) -> None:
|
||||
with self.mock_config_info(self.MOCK_DISPLAY_CONFIG_INFO), \
|
||||
self.mock_http_conversation('test_search'):
|
||||
|
|
Loading…
Reference in a new issue