The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I grep a table from Confluence to Jira through Python?

Keerthi Pandrapragada
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 4, 2024

Hi,

How can I grep a table with heading Killed tests into Jira through Python?

I have been trying it like this, but this does'nt work.

def grep_killed_tests_table(jREG_REF):
jtableinfo = []
try:
response = requests.get(jREG_REF, verify=False)
response.raise_for_status()
content = response.text
tree = html.fromstring(content)
print(f"tree: {tree}")
xpath_exp = "//table[.//th[contains(., 'Killed tests')]]"
jkilled_tests_table = tree.xpath(xpath_exp)
print(f"jkilledteststable {jkilled_tests_table}")
if jkilled_tests_table:
jtable_data = []
for row in jkilled_tests_table[0].xpath(".//tr"):
row_data = [cell.text_content().strip() for cell in row.xpath(".//td|.//th")]
if row_data:
jtable_data.append(row_data)
print(f"jtabledata{jtable_data}")
for row in jtable_data:
return jtableinfo
except requests.exceptions.RequestException as e:
print(f"{script_error} Not found {e}")
jkilled_tests_table = grep_killed_tests_table(jREG)

I want it to be updated into Jira from Confluence . Could you help me out with this?

 

Warm Regards,

Keerthi

0 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

TAGS
AUG Leaders

Atlassian Community Events