2013-07-01 5 views
2

을 작성했습니다. JIRA에서 문제를 삭제하고 생성하는 프로세스를 자동화하는 REST API의 확장 인 JIRA Python 모듈을 사용하고 있습니다. JIRA에서 다른 데이터베이스에서 수집 한 가져온 데이터를 사용하는 Python 스크립트에서 'for'루프를 사용하여 문제를 만들려고합니다. 내가 만든 데이터가 JIRA의 해당 필드와 올바르게 정렬되도록 문제를 생성 할 때 필드의 형식을 지정해야합니다. 내 파이썬 코드는 이슈를 생성하고 사용자 정의 변수에 저장되는 JIRA에 데이터를 저장하기 위해 아래에 있습니다.Python REST API를 사용하여 JIRA에서

df에는 새로운 문제점을 생성하여 JIRA에 입력하려는 13 개의 데이터 열이 들어 있습니다. 각 컬럼은 JIRA에서 발행되는 다른 필드를 나타냅니다. JIRA에서 만든 모든 새로운 문제는 각 열에서 정보를 얻어야한다 : 여기

JIRAError: HTTP 400: "{u'cqid': u"Field 'cqid' cannot be set. It is not on the appropriate screen, or unknown.", u'wistate': u"Field 'wistate' cannot be set. It is not on the appropriate screen, or unknown.", u'dateresolved': u"Field 'dateresolved' cannot be set. It is not on the appropriate screen, or unknown.", u'res': u"Field 'res' cannot be set. It is not on the appropriate screen, or unknown.", u'datecreated': u"Field 'datecreated' cannot be set. It is not on the appropriate screen, or unknown.", u'affected': u"Field 'affected' cannot be set. It is not on the appropriate screen, or unknown.", u'fixed': u"Field 'fixed' cannot be set. It is not on the appropriate screen, or unknown."}" 

가에서 만든 모든 단일 문제에 대한 JIRA에 표시되는 몇 가지 예를 들어 데이터입니다 :

from jira.client import JIRA 
import pandas as pd 

# Now we input the issues from the export.csv CSV file into the fields 
# of new issues that are being created in JIRA to replace the old ones that were 
# deleted 

df = pd.read_csv('C:\\Python27\\scripts\\export.csv') 

# Set the column names from the export.csv file equal to variables using the  
# pandas python module 

# Now do the actual loop to create new issues 

for row in df: 
    cqid = df['ClearQuest ID'] 
    summ = str(df.Summary) 
    datecreated = df['Date Created'] 
    dateresolved = df['Date Resolved'] 
    wistate = df['WI State'] 
    res = df.Resolution 
    affected = df['Affected version/s'] 
    fixed = df['Fix version/s'] 
    issue_type = df['Issue Type'] 
    priority = df.Priority 
    comments = str(df.Comments) 
    jira.create_issue(project={'key': 'DEL'}, wistate={'customfield_1001': 'WI State'}, res={'customfield_1001': 'Resolution'}, cqid={'customfield_1001': 'ClearQuest ID'}, datecreated={'customfield_1001': 'Date Created'}, dateresolved={'customfield_1001': 'Date Resolved'}, priority={'customfield_1001': 'Priority'}, fixed={'customfield_1001': 'Fixed Version'}, affected={'customfield_10004': 'affected'}, summary=summ, description=comments, issuetype={'name': 'Defect'}) 

그것은 오류를 제공합니다 코멘트 필드 :

문제 1 :
0 NaN이는
1 ... 델타는 패킷 수신부 누출 것을 찾을 수
2 T 그는 델타 항공은
6시 ... 생물 의학 메뉴, 일을 통해 IDS를 업그레이드하면 연결을 끊을 때마다 ... CP는 리터에 걸리는 때 기록받을하기로했다
4
3 NaN이 ...
5 재설정됩니다
9 재확인 구축하여 ...
8 퓨전 힙 사이즈 및 SCC1 Initia 증가 ... 생물 의학 메뉴 번째 통해 IDS 업그레이드되는
7 ... 생물 의학 메뉴 번째 통해 IDS 업그레이드 142+ , 매트가 배달 한 후에 ...
10 WPA2를 사용할 때 EAPOL 키 교환이 있습니다 ...
11 WPA2를 사용하는 경우 EA 키 echange 가고 POL ...
12 NaN의
13 NaN의
14 NaN의 ...

가 난 단지하려는 각 문제는 자신의 문자열 값을 가지고, 그리고 인덱스 번호 또는 NaN이는 표시하기 이 같은 :


문제 1 :
문제 2 : 델타는 패킷 수신부 누출 것을 찾을 수 ...
문제 3 : 델타는 연결을 끊을 때마다 ... 재설정됩니다 ...

+0

시도''()''여기를 참조 : http://pandas.pydata.org/pandas-docs/dev/basics.html#iteration 그것은 작동하지 않았다 – Jeff

+0

불행히도, 오류가 발생했습니다 : AttributeError : 'DataFrame'객체에 'itertrows'속성이 없습니다. 필자는 pander import part가 작동하는 jira.create_issue 부분이라고 생각합니다. – JMan

+0

typo! ''df.iterrows()'' – Jeff

답변

1

코드의 주요 결함 중 하나는 루핑하기 전에 데이터를 지정한다는 것입니다.

df = pd.read_csv('C:\\Python27\\scripts\\export.csv') 

for row in df: 
    cqid = row['ClearQuest ID'] 
    summary = row.Summary 
    jira.create_issue(...) 

대부분 이와 같은 조치를 취해야합니다. df.itertrows에서 행

for row in df.values: 
    cqid , summary , value3, value4, value5 = row 
+0

그것은 나에게 오류를 주었다 : cqid = row [ 'ClearQuest ID'] TypeError : 문자열 색인은 str이 아닌 정수 여야한다 ........... 나는 그것이 작동하지 않는 jira.create_issue 부분이라고 생각한다. , 팬더 파트가 아니라 루프 부분을 변경 했으므로 코드 부분의 도움을 주셔서 감사합니다 – JMan

+0

실제로 예제 CSV 데이터를 포함하면 도움이 될 것입니다. – eandersson

+0

@JMan 새로운 솔루션을 추가했습니다. – eandersson

관련 문제