Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Is it possible to use the python-jira to create an issue with a code snippet?

Filip Panovski
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 19, 2023

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 {}.

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 {}',
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.

1 answer

1 accepted

2 votes
Answer accepted
Filip Panovski
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 19, 2023

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:
{modifications_content if modifications else 'None'}

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.

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events