Is there a way to write JQL with passed in parameters?

I know JIRA doesn't have variables in JQL filters, but I was wondering if you could ask the Atlassian support for best practices on how to work around this limitation.


To give you more details, due to the integration with CDETS and with CCO Bug search, we need to update our release notes dashboards with filters that look like:


"Release note as open" not in ("1.1(1)") and fixVersion not in ("1.1(1)") and "Exclude from release notes" not in ("1.1(1)")

[this means the bug is "undecided" for release "1.1(1)"]


This has to happen for every maintenance release, and we have 4 to 5 different filters that look more or less like that one for each maintenance release.

So overall we're looking at adding 5 more filters (and a corresponding dashboard) every 6 weeks (the cadence of maintenance releases), all exactly identical except for the version label in there. And we can't drop any of them because we need to continue to release notes bugs (at least open bugs) in each maintenance release long after the release ships.


What would be ideal (and can't be done in JIRA) is:


Filter(x) = "Release note as open" not in ({x}) and fixVersion not in ({x}) and "Exclude from release notes" not in ({x})


I'm wondering if Atlassian support can suggest some compromise in between the "ideal" above and the harsh reality of cloning 5 filters and manually editing out the same label 3 times in each filter (very error prone, besides being very tedious).


Note that we can script the creation of the filters, but that does not address the other issue: with one maintenance release every 6 weeks and 5 filters per maintenance release, in a year we'll have 44 new filters to nurture.

2 answers

You tagged with the ScriptRunner tag although it seems like you don't want a scripting answer, as you already know how to create queries programatically, which is most of the battle.

You could create a JQL function called something like releaseNotesFor(1.0), which would in effect just run the query you have as an example, but I don't see that it would be that helpful because you would still need 5 queries, by the sounds of things.

I think you should forget about the queries to some extent, and focus on programatically building your dashboard or confluence page or whatever, and treat the queries as ephemeral.


I tagged with ScriptRunner because i have found a lot of your built in functions to be extremely useful and very close to being able to parameterize.  

You are correct that it should be to focus on programmatically building the dashboard or confluence page but how can the data that drives that programmatic approach be pulled and then turned around to be used to get the actual data that is wanted for said dashboard/page?  Are you suggesting REST services or some other means?   

Not really sure I understand what you mean. The data is got by the generated queries, which are used in dashboards or whatever.

What is the actual pain point here, to me it sounds like creating the 5 queries, then plugging them into a dashboard?

I was reacting to "but I don't see that it would be that helpful because you would still need 5 queries, by the sounds of things" and I wasn't focusing on the we could create our own JQL function with a parameter in it.  And I took this to mean that I would still have 5 queries that are getting modified every 6 weeks with the old baggage.  But that isn't the case once we have a custom built JQL function. So I was hoping/expecting information on how to do that.  

It looks like in your old documentation you mention it - but I haven't found the same documentation in the new page unless it is the or I go back to Atlassian documentation at  

I have written up how to create a JQL alias function here: - which also replaces the old docn you found above.

I may write some sample code on generating dashboards soon. Interested in any feedback as always.


     thanks for the writeup. One question: with JIRA v7.0.10 and Scriptrunner, it looks like inline scripts are only possible for "Script console", "Script Fields" and for "Script Listeners". As far as I can tell, inline scripts are not possible for "Script JQL Functions". Is that true or am I missing something? And is that just a roadmap item, or are there technical reasons to never expose "Script JQL Functions" inline? (I see there's a released 4.3.0 which is not installed on my JIRA instance).

I manage a JIRA instance (jira-administrators) but I don't have access to the JIRA VM console/ssh, so the only way to get to "Script JQL Functions" would be to manage them from within the JIRA Add-ons management page (not from the VM file system).


@Marco Di Benedetto - with Scriptrunner console you can do everything, the user running JIRA application can do. So even unpack TAR attached to some issue wink. See this snippet,

Yeah... Marco you are correct, there is not a text area. Jozef is also correct, you can write to the file system from a simple script, eg fetch the actual code from a url and write under the script root. But test on a test instance where you can get to the file system so you can see how it works.

I am not aware of such solution, but you are probably looking for something like this add-on using metadata as store for value returned by JQL.

If you can handle properly release dates - you can probably cover your use case with earliestUnreleasedVersion()

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


275 views 0 7
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you