Hello! I'm writing a simple script to automatically create an issue when something in our codebase occurs and show a small diff of the relevant files.
I would like to include a code block in the created issue for formatting reasons.
I've tried this so far (excerpt/code snippet):
issue_description = f"""
There has been a change in branch {repo.active_branch.name}.
The following is a list of changes:
* File modifications:
```
{modifications_content if modifications else 'None'}
```
* File additions:
```
{additions_content if additions else 'None'}
```
* File deletions:
```
{deletions_content if deletions else 'None'}
```
"""
jira_token = '...'
jira = JIRA('https://.../', basic_auth=('...', jira_token))
jira.create_issue(project='KEY', summary=f'Change for {date.today()}',
description=issue_description, issuetype={'name': 'Task'})
However this does not insert a code block and instead interprets the backticks literally. I've already looked extensively through the documentation, but haven't seen this functionality mentioned at all.
Is it possible to do this using python-jira?
Note: I've found this question that is asking the same thing using the REST API, but I would very much prefer it if I could stick to the python library and not needing to dig a level deeper.
Hold the phone!
It seems I was a bit too hasty. The triple backticks seem to only be a convenience, and the actual code snippet macro is `{code}`. So, using:
* File modifications:
{{code}}
{modifications_content if modifications else 'None'}
{{code}}
achieves the desired effect (note that I'm using an f-string above, hence the need to escape the curly braces).
I'll leave this question up in case it might help someone else out.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.