How to set Confluence permission from Jira issue?

Alvaro March 5, 2020

Hello,

I want to set automatically Confluence permissions from a Jira issue.


On the Issue the user select the permissions like "View Permission". When a other user run the transition for example "permission accepted", then I want to make a api call? (I'm not sure wich method is here the right way) that set permission on confluence. 

I know how to read the selection in the issue and how to set permission on confluence but I don't know how to work with REST Endpoint or how to give the parameters to confluence and execute my confluence script. By the way where i should put my Confluence script?

I have read the documenation but I'm still stuck... Please help me :O

 

Confluence Script - Where should I put this?

import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.spaces.SpaceManager
import com.atlassian.confluence.security.SpacePermissionManager
import com.atlassian.confluence.security.SpacePermission
import com.atlassian.user.GroupManager


//Manager
def spaceManager = ComponentLocator.getComponent(SpaceManager)
def spacePermissionManager = ComponentLocator.getComponent(SpacePermissionManager)
def groupManager = ComponentLocator.getComponent(GroupManager)


//Get a space
def targetSpace = spaceManager.getSpace("SPACEKEY")


//Spacepermission


//Get Group or User
def targetGroup = groupManager.getGroup("groupname")


if(!spacePermissionManager.getGroupsWithPermissions(targetSpace ).contains(targetGroup)) {
def spacePermission = SpacePermission.createGroupSpacePermission(SpacePermission.VIEWSPACE_PERMISSION, targetSpace , targetGroup.getName())
spacePermissionManager.savePermission(spacePermission)
}

 

Jira Script (On Transition)

//Import class 


//Manager


//Get Values from Issue

def cfValue = ....
def userForPermission = ...
def groupForPermission = ...


//Call confluence-Api and post data? How to do this?


 

Thank you :)

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events