I created a custom template.
When in use you enter variables and with that information, I would like these variables be used in a JIRA macro.
I want to list JIRA tickets based on user varables.
an example
from the template I enter variables
2014.12.11 and ECDEV
I want to be able to input those variables into a JIRA Macro.
right now i can get the template to create this URL: https://trinet.atlassian.net/issues/?jql=project%3DECDEV%20and%20fixVersion%3D2014.12.11
but it would be nice instead of the URL it creates a table of the results instead
any help would be appreciated
I figured since we solved this recently, i would add our official solution to this request which allows to inject any number of variables into any JQL filter in a Confluence Template. Below is the how-to as well as some usage notes i wrote for our company:
First we start out with determining the current syntax of the JQL Issues/Filter macro in confluence:
Copy the JIRA Issue/Filter macro syntax to a text editor, e.g.
<p> <ac:structured-macro ac:macro-id="5a45704b-a904-4440-bdc0-da68a22d5802" ac:name="jira" ac:schema-version="1"> <ac:parameter ac:name="server">JIRA</ac:parameter> <ac:parameter ac:name="columns">key,summary,type,created</ac:parameter> <ac:parameter ac:name="maximumIssues">20</ac:parameter> <ac:parameter ac:name="jqlQuery">assignee = abarylak and resolution is EMPTY </ac:parameter> <ac:parameter ac:name="serverId">c8001771-0b52-30e0-9703-562a2820710f</ac:parameter> </ac:structured-macro> </p>
Then we need to use the above syntax (a little modified) and use that for our macro.
Results are as follows:
## Macro title: JQL Filter Allowing Variables ## Macro has a body: Y ## Body processing: Rendered ## Output: JIRA Issues/Filter Macro w/ injected variables ## ## Developed by: Adam Barylak ## Date created: 2016-05-27 ## Installed by: Adam Barylak ## This macro will prompt for max number of rows and the column option, then the body will require the JQL with injected variables ## @param maxRows:title=Max Rows|type=int|required=true|default=20|desc=Enter the max rows, anything above 1000 will only display 1000 rows. ## @param columns:title=Columns|type=string|required=true|default=key,summary,type,status,assignee|desc=Enter the columns you want returned. Must be separated by commas, all lowercase, and no quotes. e.g. key,summary,assignee,test author,reporter #set ($body = $body.replaceAll("\Q<p>\E","")) #set ($body = $body.replaceAll("\Q</p>\E","")) #set ($body = $body.trim()) <p> <ac:structured-macro ac:name="jira" ac:schema-version="1"> <ac:parameter ac:name="server">JIRA</ac:parameter> <ac:parameter ac:name="columns">$paramcolumns</ac:parameter> <ac:parameter ac:name="maximumIssues">$parammaxRows</ac:parameter> <ac:parameter ac:name="jqlQuery">$body</ac:parameter> <ac:parameter ac:name="serverId">c8001771-0b52-30e0-9703-562a2820710f</ac:parameter> </ac:structured-macro> </p>
Create the macro in confluence with the following options or similar (change as needed):
Hopefully this helps others accomplish this same task. This ends up being really useful if you need to repeat a bunch of JQL filters for different things on different pages in Confluence and you don't have to store these filters as saved filters in JIRA either.
Confluence Source Editor isn't available for Cloud.
What I want is fairly simple, although clearly more complex in practice.
I want to be able to use Jira macros on Confluence pages set up as templates, and pass a variable into the parameter of the Jira macro.
Has anyone solved this for Cloud?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would be interested in a solution too.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for this workaround.
However this is a static replacement of all Variables during the creation of the page from a template by the variable-content (e.g. Text).
So once the page is created, i cannot modify the content dynamically again.
I am wondering, is there a solution to add a variable to a page, which can also be modified during "edit" and is there a way to access it from the User Macro?
There is this "Easy Confluence Variables Plugin", but as far as I can read from the documentation it allows to define variables on the space level and not on the page level during edit of the page.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is there a way to achieve similar results to define and access "variables" using the "page properties macro"?
In that case another macro is also able to access per-page defined parameter...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I ended up doing a workaround way to fix this. I use jira cloud so any on prem options were not applicable, as well, I am an end user so any plugins were really not options either.
What I ended up doing is pretty much screen scraping, so while in the editor I run some javascript I wrote, and then save the page. I keep the javascript in a bookmark and just click the bookmark when needed and it quickly loops through all the macros that I needed variables in and changes the value. Then saving the page automatically saves the new value to the database.
Here is our javascript (we needed to replace a story number in the macro):
javascript: (function () {
/*variables change below*/
var oldStoryNumber = 'XX-0000';
var newStoryNumber = 'XX-0001';
/*dont change below*/
var dataMacPar = 'data-macro-parameters';
var editInMac = 'editor-inline-macro';
/*code*/
var documentCollection = document.getElementsByTagName('iframe')[0].contentDocument.getElementsByClassName(editInMac);
function GetStoryAtrributeAndSetStory(item) {
var stringToChange = item.getAttribute(dataMacPar);
var changedString = stringToChange.replace(oldStoryNumber, newStoryNumber);
item.setAttribute(dataMacPar, changedString);
}
for (var i = 0; i < documentCollection.length; i++) {
GetStoryAtrributeAndSetStory(documentCollection[i]);
}
})();
Kind of a back end way to get what I wanted done but I figured I would share! Good Luck!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great job Adam Barylak - helped me a lot!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could create a user macro which collects the parameters and call an populate the parameters withing a JIRA macro.
You can add a external macro within your user macro using the following format.
<ac:macro ac:name="macroname"> <ac:parameter ac:name="parameter1">value1</ac:parameter> <ac:parameter ac:name="parameter2">value2</ac:parameter> </ac:macro>
Check the storage format of a page (Tools > Vier Storage Format) containing a JIRA Issues macro similar to what you want to generate to know the format of the JIRA issues macro. You should be able to pass the parameters of your macro to the JIRA issues macro.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
again... not applicable to Cloud.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.