I want to send Burndown chart to email addresses on specified intervels, is there a way I can do it?
I implemented a Python script based on selenium, and configured in the Jenkins Job.
Here are code
import os
import io
import time
from datetime import datetime
import tzlocal
from string import Template
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.wait import WebDriverWait
import argparse
from EnvDefault import env_default
from 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_id
return "?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 = None
try:
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 None
else:
sprint_id = el_sprint_ids[0].find_element_by_tag_name('a').get_attribute('data-item-id') if el_sprint_ids else None
except:
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 burndownchart
driver.get(burndown_url)
element = WebDriverWait(driver, 50).until(
lambda x: x.find_element_by_id("ghx-modes-tools"))
time.sleep(3)
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.username
password = args.password
print('username: ', username)
burndown_url = args.burndown_url
stories_url = args.stories_url
team_name = args.team_name
email_from = args.email_from
email_to = args.email_to
email_cc = args.email_cc
build_url = args.build_url
output_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 path
with 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 smtp
smtp.sendmail('internalmail.xxx.com', 25, email_from,
'', email_to, email_cc, team_name + ' Burndown Chart for ' + sprint_name, html_template, None, [burndown_image])
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
That might be more helpful here.
Regards,
Sushant Verma
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.