Hello,
How can I add specific users as watchers every time an " error " issue type created? I have checked the link below and provided scripts below does not work for me.- We use JIRA 7.1.
Thank you.
Oh man, you should do some Java tutorials to learn a bit programming.
import com.atlassian.jira.component.ComponentAccessor def watcherManager = ComponentAccessor.getWatcherManager() def userManager = ComponentAccessor.getUserManager() def issue = event.getIssue() def user1 = userManager.getUserByName("dustan") def user2 = userManager.getUserByName("gabby") def user3 = userManager.getUserByName("Phillip") def user4 = userManager.getUserByName("Gerald") def user5 = userManager.getUserByName("elif") def user6 = userManager.getUserByName("jon") if (issue.getIssueType().getName() == "New Contractor") { watcherManager.startWatching(user1, issue) watcherManager.startWatching(user2, issue) watcherManager.startWatching(user3, issue) watcherManager.startWatching(user4, issue) watcherManager.startWatching(user5, issue) watcherManager.startWatching(user6, issue) }
Just replace "Bug" with your issuetype and "robin" with your username.
import com.atlassian.jira.component.ComponentAccessor def watcherManager = ComponentAccessor.getWatcherManager() def userManager = ComponentAccessor.getUserManager() def issue = event.getIssue() def user = userManager.getUserByName("robin") if (issue.getIssueType().getName() == "Bug") watcherManager.startWatching(user, issue)
Regards,
Robin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Robin,
I am using script Listener to add the watchers and here is what I am getting. I am not familiar with wring scripts, so please be patient with me
Thank you for your understanding,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would insert the script to workflow.
Navigate Administration/Issues/Workflows
Edit the workflow you want to change.
Go to the "Create" transition, add a post function, chose "Script Post-Function" and there "Custom script post-function". Paste the code and publish workflow.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As a listener, you have to add:
def issue = event.getIssue()
to line 5.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If the project is using the default JIRA workflow - not a custom one- , will the other projects using the default Jira workflow will be impacted? Or not?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you want to use script listener, i updated my first post with the declaration of "issue".
Best,
Robin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Script Listener works!!!!! Thank you so much, you made my day!
I am curious though.If I have added the transition you have mentioned above the default workflow that my project associates with , would it impact all the other projects which have been using the default JIRA Workflow?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you edit the standard workflow, all projects using this workflow will be impacted.
So, use the Script Listener with the extended code from above.
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.
Robin,
When I added multiple people on the script I am getting this message, any ideas?
image2016-5-6 12:51:5.png
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Robin, can you please send me the command line for adding multiple users. This is what I used , but I am getting the error message I posted above.
def user = userManager.getUserByName("Amy", "Sally", "Phillip", "Jack", "elif", "john”)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thankyou @Robin Peters the script runner works excellent on JIRA 7.2.3. But, the script failed on workflow post function (custom script).Thank you so much you made my day.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Robin,
I am getting following error
Time (on server): Mon Oct 16 2017 17:37:53 GMT-0700 (Pacific Daylight Time)
The following log information was produced by this execution. Use statements like:log.info("...") to record logging information.
2017-10-16 17:37:53,779 ERROR [workflow.ScriptWorkflowFunction]: ************************************************************************************* 2017-10-16 17:37:53,779 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: CR-2024, actionId: 1, file: <inline script> groovy.lang.MissingPropertyException: No such property: event for class: Script54 at Script54.run(Script54.groovy:8)
Here's my script
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.issue.watchers.WatcherManager
def watcherManager = ComponentAccessor.getWatcherManager()
def userManager = ComponentAccessor.getUserManager()
def issue = event.getIssue()
def user = userManager.getUserByName("Brian66481")
if (issue.getIssueType().getName() == "RE Task") watcherManager.startWatching(user, issue)
Please help
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Where you want to run that script? Inside of a transition?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I'm a beginner with Script Runner and your scripts are exctly what I need, but they don't work for me.
I've tried all 3 suggested scripts and got the same error: "The variable [event] is undeclared".
I'm using Jira server 7.5.3 and wish to add a watcher as a post function to a transition.
Please advise.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is the script I am using. Ofcourse, I am using logon name where it says firstname.lastname but it isnt working for me.
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.
It's something that you could easily do with JJUPIN:
https://marketplace.atlassian.com/plugins/com.keplerrominfo.jira.plugins.jjupin/server/overview
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Steven,
I have posted the error messages I am getting below. Any idea?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Why don't the scripts in that link work for you?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.