Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Jira Notifier implementation #35397

Merged
merged 4 commits into from
Nov 17, 2023
Merged

Add Jira Notifier implementation #35397

merged 4 commits into from
Nov 17, 2023

Conversation

pubudu91
Copy link
Contributor

@pubudu91 pubudu91 commented Nov 3, 2023

Fixes #35261

Sample usage:

from datetime import datetime
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.atlassian.jira.notifications.jira import send_jira_notification

with DAG(
    "test-dag",
    start_date=datetime(2023, 11, 3),

):
    BashOperator(
        task_id="mytask",
        on_failure_callback=[
            send_jira_notification(jira_conn_id="my-jira-conn",
            description="The task failed",
            summary="Airflow Issue 1",
            project_id=10000,
            issue_type_id=10003,
            labels=["airflow-dag-failure"]
            )
        ],
        bash_command="fail",
        retries=0
    )

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

Copy link
Contributor

@Taragolis Taragolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general looks good

Just need to add tests and information into the provider documentation. Another PR's for the reference:

airflow/providers/atlassian/jira/notifications/jira.py Outdated Show resolved Hide resolved
airflow/providers/atlassian/jira/notifications/jira.py Outdated Show resolved Hide resolved
@pubudu91 pubudu91 force-pushed the fix-35261 branch 2 times, most recently from ee24614 to b684d21 Compare November 4, 2023 03:03
@pubudu91
Copy link
Contributor Author

pubudu91 commented Nov 4, 2023

@Taragolis Addressed the above mentioned suggestions. Still working on the tests and the docs.

@Taragolis
Copy link
Contributor

Documentation should be pretty simple: copy from one of existed provider, replace by new example (you have in description of PR), change reference to the Notifier classes, build it locally by run breeze build-docs atlassian.jira and check it, see:
https://github.com/apache/airflow/blob/main/BREEZE.rst#building-the-documentation

And if you need any help you might ask the questions in the Slack channel #development-first-pr-support

@pubudu91 pubudu91 force-pushed the fix-35261 branch 3 times, most recently from 00efcb4 to 539aa93 Compare November 5, 2023 06:04
@pubudu91 pubudu91 marked this pull request as ready for review November 5, 2023 06:27
Copy link
Contributor

@Taragolis Taragolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some NIT which might make it better

In general looks good, also check documentation locally

@pubudu91
Copy link
Contributor Author

pubudu91 commented Nov 5, 2023

Some NIT which might make it better

In general looks good, also check documentation locally

Built and checked the new docs locally. There weren't any issues. Will check again with the suggestions applied.

@pubudu91
Copy link
Contributor Author

pubudu91 commented Nov 5, 2023

Locally built docs:
index
image
guide
image

A small concern. We added a note saying the feature is only available from >=2.6.0. But in the above screenshots, in the left navigation the version says 2.2.0?

@Taragolis
Copy link
Contributor

the left navigation the version says 2.2.0?

That is provider version. Providers release cycle are different then Airflow itself

BashOperator(
task_id="mytask",
on_failure_callback=[
send_jira_notification(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouodn't this be JiraNotifier(...) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the notifiers seem to have followed this pattern. e.g.,

send_chime_notification = ChimeNotifier

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this pattern exists from the very first notifier.

Copy link
Contributor

@eladkal eladkal Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pattern aside.. this is an example that we publish in docs so we can change it if we wish.

Isn't on_failure_callback=ChimeNotifier(...) Works the same and is more intuitive?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pattern aside.. this is an example that we publish in docs so we can change it if we wish.

Yes, can use either approach. But then it'll look inconsistent with the existing examples in other notifier docs though. e.g., https://airflow.apache.org/docs/apache-airflow-providers-amazon/8.6.0/notifications/chime_notifier_howto_guide.html

Isn't on_failure_callback=ChimeNotifier(...) Works the same and is more intuitive?

Functionally, exactly the same. Personally for me, having an action verb in the name reads better in this context though. Like, on failure, send this notification.

@Taragolis Taragolis mentioned this pull request Nov 7, 2023
2 tasks
@pubudu91
Copy link
Contributor Author

A kind reminder on this. Are we good to merge?

@eladkal eladkal self-requested a review November 15, 2023 06:22
@eladkal eladkal merged commit 110bb0e into apache:main Nov 17, 2023
46 checks passed
@pubudu91 pubudu91 deleted the fix-35261 branch November 20, 2023 04:22
@ephraimbuddy ephraimbuddy added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Nov 20, 2023
@ephraimbuddy ephraimbuddy added this to the Airflow 2.8.0 milestone Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) provider:atlassian-jira
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add JiraNotifier
4 participants