Jira Weekly Done Issues to Slack

By
 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']

About this template

This app 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. The query filters for tickets with the status 'Done' and last updated this week. The ticket details, including the ticket URL, are posted to Slack in a single thread. The required environment variables are JIRA_DOMAIN, JIRA_EMAIL, JIRA_API_TOKEN, SLACK_TOKEN, and SLACK_CHANNEL.

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'.

Category
Technology
Last published
April 7, 2024

More templates like this

Customisable Server Status Dashboard

This template allows you to create a dashboard to report about incidents regarding your server to your users.

Streamlit
Python

A bot that answers questions about data

Ask questions about your database via a chat bot. This chatbot connects to a SQLITE database, generates queries for it based on the schema and then runs the queries printing the response all in a nicely styled chat UI. This template is pre-loaded with sample data (car parts) to play around with - here are the sample data columns that you can query: part_number, part_name, price, units_left_in_stock, manufacturer .

Python
Flask

WhatsApp Bot Builder

The WhatsApp Bot Builder app allows users to create a WhatsApp bot that responds to every message with "Hello World".

WhatsApp
Twilio
Python
Home
/
Jira Weekly Done Issues to Slack