You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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.