首页 > 解决方案 > 如何使用 Python 将 Excel 数据导出到 JIRA?

问题描述

我应该使用哪个函数来调用或更新单元格值并直接更新到 JIRA?

我有一个 excel 文件,想将其数据导出到 JIRA。我正在使用jira模块进行身份验证。

这是我从 JIRA 导出数据的脚本

import jira
from jira import JIRA
import openpyxl

workbook = openpyxl.load_workbook('C:\\Users\\Skapse\\PycharmProjects\\Import_data.xlsx')

# Get today's date
from datetime import date

today = str(date.today())
print(today)

# Authentiaction: User's credentials to be used.
username_TE = 'xxxxxxx'
password_TE = 'xxxxxxx'
# login = cryptography.fernet
server_TE = 'https://jira.technica-engineering.net/'
auth_jira_TE = JIRA(basic_auth=(username_TE, password_TE), options={'server': server_TE})

# Open Excel workbook
vk = openpyxl.Workbook()
sh = vk.active
sh = workbook.active
sh.title = today + "Data_Frm_Jira"
wb_location = "C:\\Users\\Skapse\\PycharmProjects\\Import_data.xlsx\\"

# Write headings and then write the jira data
sh.cell(1, 1).value = "Object_Ids"
sh.cell(1, 2).value = "Summary"
sh.cell(1, 3).value = "Assignee"
sh.cell(1, 4).value = "Issuetype"
sh.cell(1, 5).value = "Reporter"
sh.cell(1, 6).value = "Status"
sh.cell(1, 7).value = "Due_Date"
sh.cell(1, 8).value = "Resolution"

cell_value = sh.cell(2, 6).value
cell_val2 = sh.cell(2, 5).value

print(cell_value)
print(cell_val2)

# Get all the issues. Apply filter.
all_proj_issues_but_mine = auth_jira_TE.search_issues('project=CSQA and reporter = skapse and issuetype = "Task" and status = "OPEN"', startAt=0, maxResults=False)
print(all_proj_issues_but_mine)
row_counter = 1

#to call the cell values
for issue in all_proj_issues_but_mine:
    print("Test", issue)
    row_counter = row_counter + 1
    J_Assignee = str(issue.fields.assignee)
    print(J_Assignee)
    Resolution = str(issue.fields.resolution)
    print(Resolution)
    summary = (issue.fields.summary)
    print(summary)

# below are the cell details -        
sh.cell(row_counter, 3).value = J_Assignee
sh.cell(row_counter, 8).value = Resolution

标签: pythonjira-rest-apipython-jira

解决方案


推荐阅读