Automation: Check assignee access to Confluence page

Nikola Gaydarov June 27, 2022

Dear all,

we use Jira Server - v8.20.9.

I was tasked with a problem that seams straight forward but sadly is not.

The goal is to take from a Jira Issue the assignee and check against a link provided in a field called Environment if the user has read access or not by using Automation.

So far I have encountered the following challenges:

  • the field Environment can contain more than one link - I decided to use ";" as a delimiter so that I can read all the values  - {{issue.environment.split(';')}} 
  • How to convert normal Confluence URL to Rest-API URL?
    • For example users will provide a link like this: ".../confluence/display/Space/PageName" and for the web request I need a Url that looks like this: "/confluence/rest/api/content/12620667"
      • I found a way to do it, but actually there is another way to access Confluence pages: viewpage.action?pageId=30302710 which is bad because I am already in If-Else chain so I can not build a logic by using another IF :(
  • Is there a way to read space permissions?
  • biggest problem here is that even if you check for a page access, the user might have permission on a higher level page or from the space from a group... Any ideas?
    • for example if I write "../restriction/byOperation/update" I get 3 user names as a result, but if I write "../restriction/byOperation/read" I get Zero/Null user names, e.g. the system shows me only explicit rights given ...
  • the call can be done only for one Confluence page - {{issue.environment.split(';').get(0).trim()}}/restriction/byOperation
    • Is there a way to make a loop of web requests - for example I take 3 pages from environment, so I need to loop for 0,1 and 2 element of split?
  • the result is a list of Jira User IDs: aabbcc, ffzzmm, kkssll ....
    • How can I store this list? I think the local variable is not working for server, so only option is to store it in a field, then re-fetch and then read one-by-one and match to {{assignee.userName}} or?

All help is welcomed :)

Cheers,

Nikola

2 answers

1 accepted

0 votes
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 5, 2022

Hi @Nikola Gaydarov 

Posting some thoughts after your ping from the other thread...Note I am using Jira Cloud, not Data Center/Server, so please verify my suggestions in your environment.

Unfortunately, I do not believe the feature to help looping is supported with Data Center/Server yet: advanced branching on smart values.

So a couple of work-arounds would be to use multiple rules (one per environment) or one larger rule with an if/else structure.  Both have pros/cons, and the larger rule make not work for you as (I believe) automation rules can have a maximum of 60 components.

Kind regards,
Bill

Nikola Gaydarov July 5, 2022

Hi Bill, this is exactly what I did, but unfortunately I had to hardcode the number of the environments:

Screenshot 2022-07-05 182311.png

Sadly if I do it this way and need to have 5 or more environment the logic will be extremly long and hard to be understood.

I also heard that there is a limit of 50 elements per automation rule, so I am not even sure I can make it up to 5.

Cheers,

Nikola

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 5, 2022

Even though it will be a maintenance problem, you may want to consider multiple rules...where each one handles one-and-only-one environment.  Also consider working with your site admin to contact Atlassian Support to learn if they have other suggestions.

Nikola Gaydarov July 8, 2022

@Bill Sheboy Thanks Bill.

 

I figured out there is a third option: Short Urls.

When I try to directly send GET to the Short link I get back 403 Error.

Can you suggest a way to get a short url and somehow understand the real url behind it?

Thanks :)

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 8, 2022

No, I cannot; I have not tried that with an automation rule yet.

0 votes
Nikola Gaydarov July 5, 2022

Hi,

in case someone comes here I have managed to do all above with one exception: creating a loop to check dynamically the environments. Right now I have set a limit of 3 and the logic is build on that assumption.

Cheers,

Nikola

Suggest an answer

Log in or Sign up to answer