by Lazy Sloth
Jira Weekly Done Issues to Slack
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
import time
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.WARNING)
def format_ticket(ticket, jira_domain):
formatted_ticket = {
"Ticket ID": ticket['id'],
"Priority": ticket['fields']['priority']['name'],
"Assignee": ticket['fields']['assignee']['displayName'] if ticket['fields']['assignee'] else "Unassigned",
"URL": f"https://{jira_domain}.atlassian.net/browse/{ticket['key']}"
}
return formatted_ticket
def get_jira_credentials():
jira_domain = os.environ['JIRA_DOMAIN']
Frequently Asked Questions
How can this Jira Weekly Done Issues to Slack app benefit project managers?
The Jira Weekly Done Issues to Slack app provides project managers with an automated summary of completed tasks, enhancing visibility into team progress. By posting weekly updates to Slack, it saves time on manual reporting and keeps stakeholders informed about recent accomplishments without the need to log into Jira directly.
Can the Jira Weekly Done Issues to Slack app be customized to report on different time periods?
Yes, the app can be customized to report on different time periods. Currently, it uses the JQL query updated >= startOfWeek()
to fetch tickets updated in the current week. To modify this, you can adjust the JQL query in the get_closed_tickets
function. For example, to get tickets from the last month, you could change it to:
python
jql_query = 'status = "Done" AND updated >= startOfMonth() order by created DESC'
How does the Jira Weekly Done Issues to Slack app contribute to team transparency and communication?
The app promotes transparency by automatically sharing completed work across the team via Slack. This regular update keeps all team members and stakeholders informed about recent progress, fostering better communication and awareness of project milestones. It's particularly useful for remote or distributed teams who may not have frequent face-to-face interactions.
How can I modify the Jira Weekly Done Issues to Slack app to include additional ticket information?
To include additional ticket information, you can modify the format_ticket
function. For example, if you want to include the ticket summary and status, you could update the function like this:
python
def format_ticket(ticket, jira_domain):
formatted_ticket = {
"Ticket ID": ticket['id'],
"Summary": ticket['fields']['summary'],
"Status": ticket['fields']['status']['name'],
"Priority": ticket['fields']['priority']['name'],
"Assignee": ticket['fields']['assignee']['displayName'] if ticket['fields']['assignee'] else "Unassigned",
"URL": f"https://{jira_domain}.atlassian.net/browse/{ticket['key']}"
}
return formatted_ticket
Remember to ensure that the fields you're trying to access are available in the Jira API response.
Can the Jira Weekly Done Issues to Slack app be integrated with other project management tools besides Jira?
While the current implementation is specific to Jira, the concept of the Jira Weekly Done Issues to Slack app could be adapted for other project management tools. You would need to replace the Jira API calls with API calls to your preferred tool, and adjust the data processing accordingly. The Slack integration part of the app could remain largely unchanged, making it relatively straightforward to adapt this concept for different project management platforms that offer API access.
Created: | Last Updated:
Introduction to the Jira Weekly Done Issues to Slack Template
Welcome to the step-by-step guide on how to set up and use the Jira Weekly Done Issues to Slack template. This template is designed to help you automatically post a summary of completed Jira tasks to a specific Slack thread every week. It fetches closed tickets from Jira with the status 'Done' and updated within the current week, then formats and sends the details to a Slack channel of your choice.
To get started with this template, simply click on "Start with this Template" on the Lazy platform.
Setting Environment Secrets
Before you can use this template, you'll need to set up some environment secrets within the Lazy Builder. These secrets are necessary for the app to authenticate with Jira and Slack APIs. Here's what you need to do:
- Navigate to the Environment Secrets tab within the Lazy Builder.
- Set the following secrets with the corresponding values from your Jira and Slack accounts:
- JIRA_DOMAIN: Your Jira domain (e.g., 'yourcompany' if your Jira URL is 'yourcompany.atlassian.net')
- JIRA_EMAIL: The email address associated with your Jira account
- JIRA_API_TOKEN: Your Jira API token (You can generate one from your Jira account settings)
- SLACK_TOKEN: Your Slack API token (You can create one from the Slack API website)
- SLACK_CHANNEL: The ID of the Slack channel where you want to post updates
External Integrations
To ensure the template works correctly, you'll need to have access to both Jira and Slack. Here are the steps to set up the necessary integrations:
- Jira: Log in to your Jira account and create an API token. You can find instructions on how to do this in the Atlassian support documentation.
- Slack: Create a Slack app and generate an API token with permissions to post messages to your desired channel. Slack's API documentation can guide you through this process.
Using the Test Button
Once you have set up the environment secrets, you can use the Test button to deploy the app. The Lazy CLI will prompt you for any required user input. There are no additional user inputs required for this template outside of the environment secrets you've already set.
Using the Interface
After deploying the app using the Test button, the Lazy platform will handle the rest. It will automatically post the weekly Jira updates to the specified Slack channel. You can check the Slack channel to see the messages posted by the app.
If you need to make any adjustments or check the status of the app, you can use the Lazy Builder interface to monitor and manage the app's behavior.
That's it! You've successfully set up the Jira Weekly Done Issues to Slack template. Your Slack channel will now receive weekly updates on Jira tickets that have been marked as 'Done'.
Template Benefits
-
Improved Team Communication: This template facilitates better communication by automatically sharing completed tasks with the entire team through Slack, ensuring everyone stays informed about project progress without manual updates.
-
Time-Saving Automation: By automating the process of collecting and sharing completed Jira tickets, this template saves valuable time for project managers and team leads who would otherwise need to compile and distribute this information manually.
-
Enhanced Visibility of Achievements: Regular updates on completed tasks boost team morale and provide clear visibility of achievements, helping to motivate team members and showcase productivity to stakeholders.
-
Streamlined Project Tracking: The weekly summary of completed tasks allows for easy tracking of project milestones and progress, enabling quick identification of any bottlenecks or areas that need attention.
-
Improved Cross-Team Collaboration: By making completed tasks visible to all team members and potentially other departments through Slack, this template promotes better cross-team collaboration and alignment on project goals and progress.