@@ -32,6 +32,27 @@ def prioritize_changed_files(changed_files_map: Dict[str, str]) -> List[List[str
3232 tier3 .append (path )
3333 return [tier1 , tier2 , tier3 ]
3434
35+ def _get_task_id_from_git_info (commit_messages : str ) -> str | None :
36+ """
37+ Finds a Jira task ID by searching in common CI/CD environment variables and commit messages.
38+ Prioritizes branch names over commit messages.
39+ """
40+
41+ branch_name = os .environ .get ("GITHUB_HEAD_REF" ) or os .environ .get ("BITBUCKET_BRANCH" , "" )
42+ if branch_name :
43+ task_id = jira_client .find_task_id (branch_name )
44+ if task_id :
45+ logging .info (f"Found Jira task ID '{ task_id } ' in branch name." )
46+ return task_id
47+
48+ commit_text = " " .join (commit_messages )
49+ task_id = jira_client .find_task_id (commit_text )
50+ if task_id :
51+ logging .info (f"Found Jira task ID '{ task_id } ' in commit messages." )
52+ return task_id
53+
54+ logging .info ("No Jira task ID found in branch name or commit messages." )
55+ return None
3556
3657def filter_test_files (
3758 changed_files_map : Dict [str , str ],
@@ -196,12 +217,10 @@ def review(
196217 for path in changed_files_map .keys ()
197218 }
198219
220+ task_id = _get_task_id_from_git_info (commit_messages )
221+
199222 jira_details_text = ""
200- branch_name = os .environ .get ("BITBUCKET_BRANCH" , "" )
201- text_to_search_in = f"{ branch_name } { ' ' .join (commit_messages )} "
202-
203- task_id = jira_client .find_task_id (text_to_search_in )
204-
223+
205224 if task_id :
206225 task_details = jira_client .get_task_details (task_id )
207226 if task_details :
0 commit comments