by Gazi 👾
Jira Weekly Done Issues to Slack - Gazi's Version
import logging
import requests
import os
from datetime import datetime, timedelta
import json
from pprint import pprint
from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError
from flask import Flask, render_template_string
app = Flask(__name__)
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.WARNING)
def format_ticket(ticket, jira_domain):
story_points = ticket['fields'].get('customfield_10016', 'Not set') # Assuming 'customfield_10016' is for story points
formatted_message = f"""
Ticket Title: *{ticket['fields']['summary']}*
Ticket ID: {ticket['id']}
Priority: {ticket['fields']['priority']['name']}
Assignee: {ticket['fields']['assignee']['displayName'] if ticket['fields']['assignee'] else "Unassigned"}
Story Points: {story_points}
URL: https://{jira_domain}.atlassian.net/browse/{ticket['key']}
Frequently Asked Questions
How can this Jira Weekly Done Issues to Slack template benefit project managers?
The Jira Weekly Done Issues to Slack - Gazi's Version template provides project managers with an automated way to track and communicate progress. By summarizing completed Jira tasks in a Slack thread each week, it enhances visibility of team accomplishments, facilitates reporting, and keeps stakeholders informed without manual effort. This can lead to improved project transparency and more efficient status updates.
Can this template be customized to include additional Jira fields in the Slack message?
Yes, the template can be easily customized to include additional Jira fields. In the format_ticket
function, you can modify the formatted message to include any field available in the Jira API response. For example, to add the 'description' field, you could update the function like this:
python
def format_ticket(ticket, jira_domain):
formatted_message = f"""
Ticket Title: *{ticket['fields']['summary']}*
Ticket ID: {ticket['id']}
Priority: {ticket['fields']['priority']['name']}
Assignee: {ticket['fields']['assignee']['displayName'] if ticket['fields']['assignee'] else "Unassigned"}
Story Points: {ticket['fields'].get('customfield_10016', 'Not set')}
Description: {ticket['fields']['description']}
URL: https://{jira_domain}.atlassian.net/browse/{ticket['key']}
"""
return formatted_message.strip()
How does this Jira-Slack integration improve team communication?
The Jira Weekly Done Issues to Slack - Gazi's Version template enhances team communication by automatically sharing completed work in a centralized Slack channel. This ensures that all team members, including those who may not regularly check Jira, are aware of recent accomplishments. It can spark discussions, recognize individual contributions, and provide a clear picture of weekly progress, fostering a more collaborative and informed team environment.
Is it possible to change the frequency of updates from weekly to daily using this template?
Yes, you can modify the frequency of updates in the Jira Weekly Done Issues to Slack template. To change from weekly to daily updates, you would need to adjust the JQL query in the get_closed_tickets
function. Replace the current query with:
python
def get_closed_tickets(jira_domain, email, api_token):
jql_query = 'status = "Done" AND updated >= startOfDay() order by created DESC'
# ... rest of the function remains the same
You would also need to set up the script to run daily instead of weekly, which can be done through your server's cron job or a similar scheduling mechanism.
How can this template be adapted for use in agile sprint reviews?
The Jira Weekly Done Issues to Slack - Gazi's Version template can be a valuable tool for agile sprint reviews. It can be adapted by modifying the JQL query to match your sprint duration and adding sprint-specific information. For example, you could update the get_closed_tickets
function to fetch tickets from the current sprint:
python
def get_closed_tickets(jira_domain, email, api_token):
jql_query = 'status = "Done" AND sprint in openSprints() order by created DESC'
# ... rest of the function remains the same
You could also add a summary at the beginning of the Slack message that includes the sprint name, dates, and overall completion percentage. This would provide a comprehensive sprint review directly in Slack, facilitating remote or asynchronous sprint reviews.
Created: | Last Updated:
Introduction to the Template
This template, Jira Weekly Done Issues to Slack - Gazi's Version, provides a summary of completed Jira tasks posted to a specific Slack thread every week. It uses the Jira API to download closed tickets from the current week and posts the ticket details, including the ticket URL and Jira story points, into a Slack message thread.
Getting Started
To get started with this template, click Start with this Template.
Initial Setup
This template requires setting up environment secrets. Follow these steps to configure the necessary environment secrets:
- JIRA_DOMAIN: Your Jira domain (e.g., 'your-company').
- JIRA_EMAIL: Your Jira account email.
- JIRA_API_TOKEN: Generate this from your Atlassian account settings. Learn how to generate an API token.
- SLACK_TOKEN: Generate this from the Slack API website. Learn how to generate a Slack token.
- SLACK_CHANNEL: The channel ID where updates will be posted. You can find the channel ID by right-clicking on the channel name in Slack and selecting "Copy Link". The channel ID is the last part of the URL.
Set these as environment secrets in the Environment Secrets tab within the Lazy Builder.
Test
Press the Test button to begin the deployment of the app. The Lazy CLI will prompt you for any required user input.
Using the App
Once the app is deployed, it will provide a web interface accessible via a dedicated server link. The interface includes a button to manually trigger the weekly Jira update.
- Open the provided server link.
- Click the "Run Update" button to manually trigger the Jira update.
Integrating the App
The app will automatically post weekly updates to the specified Slack channel. If you need to integrate this app further, follow these steps:
- Jira Integration: Ensure your Jira account has the necessary permissions to access the tickets and generate API tokens.
- Slack Integration: Ensure your Slack app has the necessary permissions to post messages in the specified channel. You may need to add the
chat:write
scope to your Slack app.
Sample Slack Message
Here is an example of what the Slack message will look like:
Ticket Title: *Sample Ticket Title*
Ticket ID: 12345
Priority: High
Assignee: John Doe
Story Points: 5
URL: https://your-company.atlassian.net/browse/ABC-123
By following these steps, you can successfully set up and use the Jira Weekly Done Issues to Slack - Gazi's Version template to keep your team updated on completed Jira tasks.
Here are 5 key business benefits for this template:
Template Benefits
-
Improved Team Communication: By automatically posting weekly summaries of completed Jira tasks to Slack, this template enhances team-wide visibility of progress and accomplishments, fostering better communication and collaboration.
-
Time-Saving Automation: The template eliminates the need for manual reporting, saving valuable time for project managers and team leads who would otherwise need to compile and share this information manually.
-
Increased Accountability: Regular updates on completed tasks encourage team members to close their tickets promptly and accurately, promoting better task management and accountability.
-
Data-Driven Decision Making: By providing a consistent view of completed work, including story points, this tool enables managers to make more informed decisions about team capacity, productivity, and project timelines.
-
Enhanced Project Transparency: Stakeholders and team members alike benefit from increased transparency into project progress, helping to align expectations and identify potential bottlenecks or areas of high productivity.