You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I'm using ScriptRunner "Script Listeners" in order to send notifications whenever a user or a group have been attributed a role or removed from a projet role.
I tried listening on these events "ProjectUpdatedEvent,RoleMembershipCreatedEvent, RoleUpdatedEvent, RoleMembershipDeletedEvent" BUT NONE HAS BEEN TRIGGERED SO FAR even though I have done the following :
Any help on how to achieve what I want to do?
Hi @Amine Filali,
I used "ProjectRoleUpdatedEvent", and it triggers mail to me whenever user added/removed in user and roles
used below script for sending test mails
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.mail.Email
import com.atlassian.mail.server.SMTPMailServer
def emailBody = "Hi Leo, \n\nUser role updated"
sendEmail("user@mail.com", "User role updated", emailBody)
def sendEmail(String emailAddr, String subject, String body) {
SMTPMailServer mailServer = ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer()
if (mailServer) {
Email email = new Email(emailAddr)
email.setSubject(subject)
email.setBody(body)
mailServer.send(email)
log.warn("Mail sent")
} else {
log.warn("Please make sure that a valid mailServer is configured")
}
}
Hope this gives you an idea
BR,
Leo
Hi @Leo
Praying that you do see this message. And, hoping that you can help me.
I am using ProjectRoleUpdateEvent to catch whenever a new user is added to any role in any project. I am able to get who does that and what permissions he has.
But my real need is to find which role he modified and which user he added or removed. Can you please help me if you know, what class, method, command do I need to import or invoke to find this information from inside of scriptrunner script.
regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Leo hello,
thanks for posting the script. but, i'm confused becuase i'm getting an error "Cannot send mail as no outgoing mail set up". we have configured mail handlers already in jira. where should i give the mail handler details in the script?
Thanks
Sai
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.