Skip to content
Permalink
Browse files
Merge pull request #4 from knaufk/hotfix-jira
[hotfix] fix runtime errors in flink_jira_bot.py
  • Loading branch information
knaufk committed Apr 14, 2021
2 parents 4cc0b90 + 310b9cc commit 93679d9fdd56cc6c0fd2850f08637bf5d8299a5e
Showing 1 changed file with 18 additions and 16 deletions.
@@ -21,7 +21,6 @@
import confuse
import os
import abc
import sys
from argparse import ArgumentParser
from pathlib import Path

@@ -47,7 +46,7 @@ def add_label(self, issue, label):
key = issue["key"]

if not self.is_dry_run:
self.jira.update_issue_field(key, fields)
self.jira_client.update_issue_field(key, fields)
else:
logging.info(f'DRY RUN ({key}): Adding label "{label}".')

@@ -58,21 +57,21 @@ def replace_label(self, issue, old_label, new_label):
key = issue["key"]

if not self.is_dry_run:
self.jira.update_issue_field(key, fields)
self.jira_client.update_issue_field(key, fields)
else:
logging.info(
f'DRY RUN ({key}): Replace label "{old_label}" for "{new_label}".'
)

def add_comment(self, key, comment):
if not self.is_dry_run:
jira.issue_add_comment(key, comment)
self.jira_client.issue_add_comment(key, comment)
else:
logging.info(f'DRY_RUN ({key}): Adding comment "{comment}".')

def close_issue(self, key):
if not self.is_dry_run:
jira.issue_transition(key, "Closed")
self.jira_client.issue_transition(key, "Closed")
else:
logging.info(f"DRY_RUN (({key})): Closing.")

@@ -88,6 +87,7 @@ def __init__(self, jira_client, config, is_dry_run):
self.warning_days = config["stale_minor"]["warning_days"].get()
self.warning_label = config["stale_minor"]["warning_label"].get()
self.done_label = config["stale_minor"]["done_label"].get()
self.done_comment = config["stale_minor"]["done_comment"].get()
self.warning_comment = config["stale_minor"]["warning_comment"].get()

def run(self):
@@ -96,7 +96,10 @@ def run(self):

def close_tickets_marked_stale(self):

minor_tickets_marked_stale = f'project=FLINK AND Priority = Minor AND resolution = Unresolved AND labels in ("{self.warning_label}") AND updated < startOfDay(-{self.warning_days}d)'
minor_tickets_marked_stale = (
f"project=FLINK AND Priority = Minor AND resolution = Unresolved AND labels in "
f'("{self.warning_label}") AND updated < startOfDay(-{self.warning_days}d)'
)
logging.info(
f"Looking for minor tickets, which were previously marked as stale: {minor_tickets_marked_stale}"
)
@@ -120,7 +123,10 @@ def close_tickets_marked_stale(self):

def mark_stale_tickets_stale(self):

stale_minor_tickets = f"project = FLINK AND Priority = Minor AND resolution = Unresolved AND updated < startOfDay(-{self.stale_days}d)"
stale_minor_tickets = (
f"project = FLINK AND Priority = Minor AND resolution = Unresolved AND updated < "
f"startOfDay(-{self.stale_days}d)"
)
logging.info(
f"Looking for minor tickets, which are stale: {stale_minor_tickets}"
)
@@ -145,15 +151,11 @@ def mark_stale_tickets_stale(self):

else:
logging.info(
f"Found https://issues.apache.org/jira/browse/{key}, but is has recently updated Subtasks. Ignoring for now."
f"Found https://issues.apache.org/jira/browse/{key}, but is has recently updated Subtasks. "
f"Ignoring for now."
)


def is_dry_run():
opts = [opt for opt in sys.argv[1:] if opt.startswith("-")]
return "-d" in opts


def get_args():
parser = ArgumentParser(description="Apache Flink Jira Bot")
parser.add_argument(
@@ -179,14 +181,14 @@ def get_args():

args = get_args()

config = confuse.Configuration("flink-jira-bot", __name__)
config.set_file(args.config)
jira_bot_config = confuse.Configuration("flink-jira-bot", __name__)
jira_bot_config.set_file(args.config)

jira = Jira(
url="https://issues.apache.org/jira",
username="flink-jira-bot",
password=os.environ["JIRA_PASSWORD"],
)

rule_3 = Rule3(jira, config, args.dryrun)
rule_3 = Rule3(jira, jira_bot_config, args.dryrun)
rule_3.run()

0 comments on commit 93679d9

Please sign in to comment.