REST API の拡張機能である JIRA Python モジュールを使用して、JIRA で課題を削除および作成するプロセスを自動化しています。別のデータベースから収集したインポート データを使用する Python スクリプトで「for」ループを使用して、JIRA で課題を作成しようとしています。課題を作成するときにフィールドをフォーマットする必要があるため、持っているデータが JIRA の適切なフィールドと適切に一致するようになります。問題を作成し、カスタム変数に保存されている JIRA に入れるデータを保存するための私の Python コードを以下に示します。
df には、新しい課題を作成して JIRA に入力したい 13 列のデータが含まれています。各列は、JIRA の課題の異なるフィールドを表します。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'})
エラーが発生します:
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 に表示されるデータの例です。
問題 1:
0 NaN
1 デルタがパケット受信をリークすることが判明しました...
2 切断するたびにデルタがリセットされます...
3 NaN
4 CP が停止するとログに記録されるはずです...
5 経由で IDS をアップグレードすると、 BioMed メニューで...
6 BioMed メニューで IDS を
アップグレードすると... 7 BioMed メニューで IDS をアップグレードすると...
8 Fusion ヒープ サイズと SCC1 Initia の増加...
9再確認ビルド 142+ を使用して、Matt が提供した後 ...
10 WPA2 を使用する場合、EAPOL キー echange go があります...
11 WPA2 を使用する場合、EAPOL key echange go があります...
12 NaN
13 NaN
14 NaN ...
各問題に独自の文字列値を持たせたいだけで、インデックス番号や NaN を次のように表示したくはありません。
問題 1:
問題 2: デルタが受信パケットをリークすることが判明しました...
問題 3: 切断するたびにデルタがリセットされます ... ...