jiratools package¶
Some simple API functions and command-line tools for interaction with JIRA.
-
jiratools.
add_comment
()[source]¶ Quick “add a short comment to a JIRA” command line tool.
If ‘message’ is ‘-‘ then stdin will be read.
- Return type
None
-
jiratools.
format_as_code_block
(text_to_wrap)[source]¶ Wrap the text in a JIRA code block.
- Parameters
text_to_wrap (
str
) – The text to wrap.- Return type
str
- Returns
A JIRA formatted code block.
Submodules¶
jiratools.assignee module¶
Issue Reassignment command.
jiratools.comment module¶
Add Comment command.
jiratools.do_search module¶
Search command.
jiratools.error_logger module¶
Error logging for jiratools.
-
class
jiratools.error_logger.
JiraEntry
[source]¶ Bases:
object
Typing mock for Jira Entry data.
-
error_message
: str¶
-
jira_id
: str¶
-
-
jiratools.error_logger.
add_jira_comment_with_table
(jira_id, data_headers, data_array, msg_prefix='', **format_kwargs)[source]¶ Add a comment to a JIRA with a formatted data table.
- Parameters
jira_id (
str
) – the Issue ID of the JIRA to be updateddata_headers (
List
[str
]) – a list of header column namesdata_array (
List
[List
[Union
[str
,int
]]]) –An array of lists of strings, representing table rows. e.g.:
[["a", "b", "c"], ["d", "e", "f"]]
**format_kwargs – formatting keyword args to be passed to jiratools.formatting.format_jira_msg
- Returns
the Issue ID of the JIRA which received the comment
- Return type
str
-
jiratools.error_logger.
add_jira_error_comment
(jira_id, error_msg, **format_kwargs)[source]¶ Add a comment to a JIRA with a formatted error message.
- Parameters
jira_id (
str
) – the Issue ID of the JIRA to be updatederror_msg (
str
) – the raw error message to include in the comment**format_kwargs – formatting keyword args to be passed to jiratools.formatting.format_jira_msg
- Return type
str
- Returns
the Issue ID of the JIRA which received the comment
-
jiratools.error_logger.
update_jira_for_errors
(jiras, *errors, **format_kwargs)[source]¶ Auto-Update JIRAs if errors are found that match the jira list.
- Parameters
jiras (
Iterable
[JiraEntry
]) –an iterable of objects that each contain two required attributes
jira_id: the Issue Id of the JIRA to be updated
error_message: an error message substring which, if found, will trigger and update of the JIRA with the actual error message.
*errors – an error message to be checked against the
jiras
for a match**format_kwargs – formatting keyword args to be passed to jiratools.formatting.format_jira_msg
- Return type
List
[str
]- Returns
A list of JIRA Issue IDs that were updated.
jiratools.example_config module¶
Build Example Config.
jiratools.formatting module¶
Formatting helpers for jiratools.
-
jiratools.formatting.
format_as_jira_table
(headers, data_array)[source]¶ Build a JIRA table given headers and row data.
- Parameters
headers (
List
[str
]) – a list of header column namesdata_array (
List
[List
[Union
[str
,int
]]]) –An array of lists, representing table rows. e.g.:
[["a", "b", "c"], ["d", "e", "f"]]
- Return type
str
- Returns
a formatted JIRA table
-
jiratools.formatting.
format_autoupdate_jira_msg
(message_body, header_body=None)[source]¶ Format a JIRA message with useful headers.
An “Automated JIRA Update” title will be added, as well as either a URL link if a
BUILD_URL
env variable is present, or a note indicating a manual run with user id otherwise.- Parameters
message_body (
str
) – the body of the messageheader_body (
Optional
[str
]) – a header to be added withh2
tag
- Return type
str
- Returns
a formatted message with headers
jiratools.helpers module¶
A collection of helpers for JIRA commands.
-
jiratools.helpers.
add_comment
(jira_id, comment_text)[source]¶ Add a comment to the JIRA ID.
- Parameters
jira_id (
str
) – The JIRA ID to comment on.comment_text (
str
) – The text to add as the comment body.
- Return type
Comment
- Returns
A jira comment.
-
jiratools.helpers.
check_for_valid_user
(user)[source]¶ Ensure that a user exists, exit if not found.
- Parameters
user (
str
) – the user id- Return type
None
-
jiratools.helpers.
component_id_from_name
(project_components, component_name)[source]¶ Retrive the id of the compoment with the desired name.
- Parameters
project_components (
List
[Component
]) – a list of all components associated with a JIRA projectcomponent_name (
str
) – the name of the desired component
- Return type
str
- Returns
the id of the matching component
-
jiratools.helpers.
get_issue_by_id
(jira_id)[source]¶ Find the JIRA of a given id, or exit if not found.
- Parameters
jira_id (
str
) – the id of the desired JIRA- Return type
Issue
- Returns
the issue with the provided id
-
jiratools.helpers.
link_jiras
(from_jira, to_jira, relation_type='relates to', client=None)[source]¶ Create a link between two JIRA issues.
- Parameters
from_jira (
str
) – a JIRA issue idto_jira (
str
) – a JIRA issue idrelation_type (
str
) – the type of link relationshipclient (
Optional
[JIRA
]) – the instantiated JIRA client
- Return type
Response
- Returns
the client Response
jiratools.link module¶
Link JIRAs command.
jiratools.make_and_link module¶
Make a linked story command.
jiratools.utils module¶
Basic utility functions for JIRA tools.
-
exception
jiratools.utils.
ConfigNotFoundException
[source]¶ Bases:
Exception
Exception for config failure.