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

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,348
Community Members
 
Community Events
176
Community Groups

Share board via mail using scriptrunner

Edited

Hi everyone,

I would like to send a mail with a link of the current board.

I'm using scriptrunner but I m not able to find the current id or url...

Can anyone help me?

1 answer

Hi @Tommaso Scorteccia

For your requirement, you can try to trigger the email using the ScriptRunner console with something like this:-

import com.atlassian.greenhopper.service.rapid.view.RapidViewService
import com.atlassian.greenhopper.web.rapid.view.RapidViewHelper
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.mail.Email
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import groovy.xml.MarkupBuilder

@WithPlugin("com.pyxis.greenhopper.jira")

@JiraAgileBean
RapidViewService rapidViewService

@JiraAgileBean
RapidViewHelper rapidViewHelper

def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def applicationProperties = ComponentAccessor.applicationProperties
def hostUrl = applicationProperties.getString('jira.baseurl')
def views = rapidViewService.getRapidViews(loggedInUser).value
final def projectKey = 'MOCK'

def emailBody = new StringWriter()
def html = new MarkupBuilder(emailBody)

html.html {
body {
views.each {
if (it.name == "${projectKey} board") {
a ( href : "${hostUrl}/secure/RapidBoard.jspa?rapidView=${it.id}&projectKey=${projectKey}") {
mkp.yield "Link to ${projectKey} board"
}
}
}
}
}

final static creatMessage(String to, String subject, String content) {
def mailServerManager = ComponentAccessor.mailServerManager
def mailServer = mailServerManager.defaultSMTPMailServer

def email = new Email(to)
email.setSubject(subject)
email.setMimeType("text/html")
email.setBody(content)

def threadClassLoader = Thread.currentThread().contextClassLoader
Thread.currentThread().contextClassLoader = mailServer.class.classLoader
mailServer.send(email)
Thread.currentThread().contextClassLoader = threadClassLoader
}

creatMessage('user@samplemail.com', 'Board Link', emailBody.toString())

Please note that the sample code provided is not 100% exact to your environment. Hence, you will need to modify it accordingly.

Below is a print screen of the email link received:-

email_link.png

Upon clicking the link, the receiver is re-directed to the board. However, you must ensure that the receiver has the required permission to view the board. 

I hope this helps to answer your question. :)

 

Thank you and Kind regards,

Ram

Hi @Ram Kumar Aravindakshan _Adaptavist_ , thank you for the example

I'm trying your script, but my board structure is quite difference, I have a one project with different board inside. For example

Project "Apple"

Boar "Develop Board"

Board "Testing Board" and so on..

I see that to identify the board you use the condition

if (it.name == "${projectKey} board")

but I can't use this condition for my scope 

What i want to do is a button in the board that send a link like window.location.href in javascript, or a function like "getcurrentboard" :)

Thank in advance

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events