Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Change email for all Projects using script runner

Hello.


I need to change project email for all of my projects in JIRA.

There are hundreds of them so I would like to know if script runner is capable of this?

I've been struggling with this for some time now.

1 answer

Suggest an answer

Log in or Sign up to answer
1 vote
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Dec 28, 2017

Yes, a one-off script run in the console could use the ProjectManager class to update every project

There are methods of getting the mail, but I cannot see how to set the email for the project.

I've been looking through 
https://docs.atlassian.com/software/jira/docs/api/7.0.11/com/atlassian/jira/project/

and these 2 stand out, but nothing on how to set the email.

https://docs.atlassian.com/software/jira/docs/api/7.0.11/com/atlassian/jira/project/ProjectManager.html

https://docs.atlassian.com/software/jira/docs/api/7.0.11/com/atlassian/jira/project/Project.html

Could you give me some pointers ?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Dec 28, 2017

Ah, hang on, what exactly do you mean by "project email"?

In the project configuration under notification you can specify the notification scheme and an email.

F.x.
Scheme: Notification Scheme name
Email: xxx@company.xx

I need to change this email on all projects.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Dec 28, 2017

Ah good, I could have pointed you in completely the wrong direction!

I think you combine ProjectManager with ProjectEmail.setFromAddress(email) - https://docs.atlassian.com/software/jira/docs/api/7.0.11/index.html?com/atlassian/jira/project/ProjectManager.html

Thanos Batagiannis [Adaptavist]
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.
Dec 28, 2017

Hi Sigursteinn,

What @Nic Brough -Adaptavist- said (a one time script using the script console)

So the script that will change it for one project is 

import com.atlassian.core.ofbiz.util.OFBizPropertyUtils
import com.atlassian.jira.component.ComponentAccessor

def newAddress = "newEmail@example.com"
def project = ComponentAccessor.projectManager.getProjectByCurrentKey("ATG")

def email = OFBizPropertyUtils.getPropertySet(project.getGenericValue())
email.setString("jira.project.email.sender", newAddress)

So for all the projects will be something like 

import com.atlassian.core.ofbiz.util.OFBizPropertyUtils
import com.atlassian.jira.component.ComponentAccessor

def
newAddress = "newEmail@example.com"
ComponentAccessor.projectManager.projects.each {
def email = OFBizPropertyUtils.getPropertySet(it.getGenericValue())
email.setString("jira.project.email.sender", newAddress)
}

Regards, Thanos

Thank you so much Thanos, that did the trick :)

TAGS
AUG Leaders

Atlassian Community Events