diff --git a/dev/create_spark_jira.py b/dev/create_spark_jira.py index 287a2d2e3a27..907f9243092e 100755 --- a/dev/create_spark_jira.py +++ b/dev/create_spark_jira.py @@ -38,6 +38,16 @@ def main(): help="Issue type (e.g. Bug, Improvement)", ) parser.add_argument("-c", "--component", help="Component for the issue") + parser.add_argument( + "-d", + "--description", + help="Description text for the issue.", + ) + parser.add_argument( + "--description-file", + help="Path to a file whose contents are used as the issue description " + "(mutually exclusive with --description).", + ) parser.add_argument( "--list-components", action="store_true", help="List available components and exit" ) @@ -60,9 +70,25 @@ def main(): if not args.parent and not args.type: parser.error("-t/--type is required when not creating a subtask") + if args.description and args.description_file: + parser.error("--description and --description-file cannot be used together") + + description = args.description or "" + if args.description_file: + try: + with open(args.description_file, encoding="utf-8") as f: + description = f.read() + except OSError as e: + parser.error("cannot read --description-file: %s" % e) + asf_jira = get_jira_client() jira_id = create_jira_issue( - asf_jira, args.title, args.component, parent=args.parent, issue_type=args.type + asf_jira, + args.title, + args.component, + parent=args.parent, + issue_type=args.type, + description=description, ) print(jira_id) diff --git a/dev/spark_jira_utils.py b/dev/spark_jira_utils.py index 4fc8dd5f5497..67d205dbf263 100644 --- a/dev/spark_jira_utils.py +++ b/dev/spark_jira_utils.py @@ -78,14 +78,16 @@ def list_components(asf_jira): print(c.name) -def create_jira_issue(asf_jira, title, component, parent=None, issue_type=None, version=None): +def create_jira_issue( + asf_jira, title, component, parent=None, issue_type=None, version=None, description="" +): """Create a JIRA issue and return the issue key (e.g. SPARK-12345).""" affected_version = version if version else detect_affected_version(asf_jira) issue_dict = { "project": {"key": "SPARK"}, "summary": title, - "description": "", + "description": description or "", "versions": [{"name": affected_version}], "components": [{"name": component}], }