I am trying to write a post function using script runner to add watchers to the issue when created depending on components.
I was able to get the watchers to be added but i am not able to get a condition check with component working. How do i get a list of components for the issue and then define a user list to be added as watchers.
Apologies, my scripting capabilities are somewhat limited. I took a look at the link but I'm not sure it suits the use case. Upon issue creation (post function) I need a watcher to be automatically added based on a component selected. I couldn't find that information in the link.
There is a sample for this here: https://scriptrunner.adaptavist.com/latest/jira/testing/testing-workflow-functions.html#_example_scenario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi @JamieA , thanks for the sharing the sample! the sample is for adding the component's lead to the Watchers (field), is there a sample for adding component watcher/s to the Watchers in the ticket (when the component is selected)? For ex: Component A has watcher1 and watcher2, when Component A is selected, both of watcher1 and watcher2 are added to Watchers field.
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.
hi @Henry Lin what do you mean by "component watchers"?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi @Martin Bayer _MoroSystems_ s_r_o__ , sorry, I wasn't cleared about it, I was referring to this plugin Component Watcher for Jira.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Henry Lin I was not aware of this App, but I'm checking its source code and documentation
It looks like there is no public Java API, but there is public REST API. I can see, there are two endpoints which accept "project key" as a parameter
/rest/componentwatchers/1.0/groups/{projectkey}
Response of both endpoints contains this "section" of data
{ "projectKey": "TST", "projectName": "Test", "component": "Design", "watchers": [] }
watchers will containt data you need. There will be user's identifiers when using "/users/" endpoint and group's identifiers for "/groups/" endpoint
For users
You can use https://docs.atlassian.com/software/jira/docs/api/7.6.1/index.html?com/atlassian/jira/user/util/UserManager.html to get the ApplicationUser based on the key
For groups
You need to get group members using https://docs.atlassian.com/software/jira/docs/api/7.6.1/index.html?com/atlassian/jira/security/groups/GroupManager.html and method
Collection<ApplicationUser> getUsersInGroup(String groupName)
Then you have collection of all users configured as component watchers which can be used in script posted by @JamieA to add users to watchers.
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.
@Jamie Echlin [Adaptavist], can you help with this? I'm just trying to get the script to run for adding watchers upon issue create.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Hermant, I'm trying to do the same thing- can you share the script you used to add watchers upon create issue?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For example the following would be true if there is a component call Foo selected:
"Foo" in issue.getComponents()*.name
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.