Jump Start for custom macro development

Dear devs,

im planning for the future to create a macro for our in-house needs.
I had and will have a look at: Writing a Macro

Could you name any existing macro as a reference project? My goals are the following:

  • the macro has at least one parameter (integer id)
  • on rendering, the macro makes a request to a RESTful service in our network, getting information for the id (ticket object), for this, it needs to authenticate using Bearer Authentication
  • the rendered macro displays for example #3423 :white_check_mark: if the issue ist testok and the text in strikethrough when the issue is Closed etc.

My best guess is the JIRA Macro? It looks exactly (epic) like what I want (but we don’t use JIRA :frowning: )
So the jira github should get me started?

Thank you,
BR Mario

Hi there.

You could also check https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Tutorials/WritingMacros/ if you haven’t done so.

So you’ll need to decide if you want to write a macro in java or in a wiki page. The link I pasted has both.

Your goals seem good and simple so it shouldn’t be too hard.

I don’t know if you’re a java dev or not. If not, you should use a wiki macro and use groovy to achieve what you want. It’s very easy to do an HTTP call and parse the result (JSON, XML, etc) in Groovy (it’s done in 1 line).

The JIRA macro is ok as an example yes if you want to develop a java macro. It’s more complex than what you need but it’s a good example since it also contributes some Admin UI to configure the remote server to use, and more.

yup that’s correct.

You may need some knowledge about xwiki components along the way: https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Tutorials/WritingComponents/

Thanks for your fast response.

Well I’m no dev at all (technical support), and it’s been a few years since java for me.
But I don’t know groovy either :smiley:

But i guess I will start trying to write the macro in a wiki page, so I don’t have to setup the whole java dev environment.

BR