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?
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:-
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
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.