I want to send Burndown chart to email addresses on specified intervels, is there a way I can do it?
Hi @Anand Kumar JIRA does not natively have the ability to do this currently.While there are some suggested work-around in the comments of that page, I found a related post over at
https://community.atlassian.com/t5/JIRA-questions/Emailing-BI-Dashboard-Reports-from-JIRA/qaq-p/243952
That might be more helpful here.Regards,Sushant Verma
Hi @Anand Kumar what you could consider is to copy the report link and use it in an automation rule.
trigger - scheduled
action - send email and add link to the body of the email
with that said generally viewing the burn down is a good way to start a daily scrum meeting. Maybe you are sending outside of the scrum team?
I implemented a Python script based on selenium, and configured in the Jenkins Job.
Here are code
import osimport ioimport timefrom datetime import datetimeimport tzlocalfrom string import Templatefrom selenium import webdriverfrom selenium.webdriver.common.keys import Keysfrom selenium.webdriver.chrome.options import Optionsfrom selenium.webdriver.support.wait import WebDriverWaitimport argparsefrom EnvDefault import env_defaultfrom urllib import parse
code_repo="https://xxx.xxx.com/burndown-chart.git"
def append_sprint_id(url, sprint_id):if "?" in url:return url + "&sprint=" + sprint_idreturn "?sprint=" + sprint_id
def generate_chart(driver, burndown_url, stories_url, username, password, output_location) :driver.get(stories_url)
WebDriverWait(driver, 50).until(lambda x: x.find_element_by_id("login-form-username"))
driver.maximize_window()
el_user = driver.find_element_by_id("login-form-username")el_password = driver.find_element_by_id("login-form-password")el_user.clear()el_user.send_keys(username)el_password.clear()el_password.send_keys(password)driver.find_element_by_id("login-form-submit").click()
# element = WebDriverWait(driver, 50).until(# lambda x: x.find_element_by_id("ghx-chart-wrap"))
time.sleep(3)
#pick up sprint name, days left etc.''el_sprint_ids = driver.find_elements_by_css_selector('div#subnav-opts-work div.aui-dropdown2-section ul.aui-list-truncate li')sprint_id = Nonetry:print("el_sprint_ids:", len(el_sprint_ids))
if len(el_sprint_ids) > 1:project_key=parse.parse_qs(parse.urlparse(stories_url).query)['projectKey'][0]print("project_key:", project_key)
el_sprints = [el_sprint_item for el_sprint_item in el_sprint_ids if project_key in el_sprint_item.find_element_by_tag_name('a').get_attribute("innerHTML")]print("el_sprints:", len(el_sprints))sprint_id = el_sprints[0].find_element_by_tag_name('a').get_attribute('data-item-id') if el_sprints else Noneelse:sprint_id = el_sprint_ids[0].find_element_by_tag_name('a').get_attribute('data-item-id') if el_sprint_ids else Noneexcept:pass
print("sprint_id:", sprint_id)
if sprint_id:stories_url=append_sprint_id(stories_url, sprint_id)burndown_url=append_sprint_id(burndown_url, sprint_id)driver.get(stories_url)time.sleep(2)
el_sprint_name = driver.find_elements_by_css_selector('span#subnav-title span.subnavigator-title')sprint_name = el_sprint_name[0].text if el_sprint_name else "unknow"print(sprint_name)
el_days_left = driver.find_elements_by_css_selector('span.time span.days-left')days_left = el_days_left[0].text if el_days_left else "unknow"print(days_left)
#generate the burndownchartdriver.get(burndown_url)
element = WebDriverWait(driver, 50).until(lambda x: x.find_element_by_id("ghx-modes-tools"))
el_ghx = driver.find_element_by_id('ghx-chart-wrap')driver.execute_script("return arguments[0].scrollIntoView();", el_ghx)time.sleep(3)
burndown_image = output_location + '/burndownChart.png'image = el_ghx.screenshot(burndown_image)
return sprint_name, days_left, burndown_image
if __name__ == '__main__':parser = argparse.ArgumentParser()parser.add_argument("--username",type=str,action=env_default('JIRA_USERNAME'),required=True,dest='username',help="JIRA username")parser.add_argument("--password",type=str,action=env_default('JIRA_PASSWORD'),required=True,dest='password',help="JIRA password")parser.add_argument("--burndown-url",type=str,required=True,dest='burndown_url',help="burndown Chart url")parser.add_argument("--stories-url",type=str,required=True,dest='stories_url',help="Stories url")parser.add_argument("--team-name",type=str,required=True,dest='team_name',help="Team Name")parser.add_argument("--email-from",type=str,required=True,dest='email_from',help="Email from")parser.add_argument("--email-to",type=str,required=True,dest='email_to',help="Email Recipients")parser.add_argument("--email-cc",type=str,required=False,dest='email_cc',help="Email Copy")parser.add_argument("--build-url",type=str,required=False,dest='build_url',help="build-url, Jenkins buil url")parser.add_argument("--output-location",type=str,required=True,dest='output_location',help="Output location")
args = parser.parse_args()username = args.usernamepassword = args.password
print('username: ', username)burndown_url = args.burndown_urlstories_url = args.stories_urlteam_name = args.team_nameemail_from = args.email_fromemail_to = args.email_toemail_cc = args.email_ccbuild_url = args.build_urloutput_location = args.output_location
options = Options()options.add_argument("--kiosk")options.add_argument("--headless")options.add_argument("--window-size=1920x1080")
import chromedriver_binary # Adds chromedriver binary to pathwith webdriver.Chrome(options=options) as driver:sprint_name, days_left, burndown_image = generate_chart(driver, burndown_url, stories_url, username, password, output_location)
html_template=''with open('./template.html', 'rb') as fp:html_template = Template(str(fp.read(), 'utf-8'))template_dict= {"days_left": days_left,"team_name": team_name,"image_cid": burndown_image,"burndown_url": burndown_url,"stories_url": stories_url,"build_url": build_url,"code_repo": code_repo,"sprint_name": sprint_name,"generate_time": datetime.now(tzlocal.get_localzone()).strftime("%a, %d/%m/%Y, %H:%M:%S %Z")}html_template=html_template.safe_substitute(**template_dict)
print(html_template)
import smtpsmtp.sendmail('internalmail.xxx.com', 25, email_from,'', email_to, email_cc, team_name + ' Burndown Chart for ' + sprint_name, html_template, None, [burndown_image])
It looks like you're new here. Sign in or register to get started.