Created
September 28, 2018 05:28
-
-
Save sin-tanaka/320f6135dee478b65f357f37cc50ac9b to your computer and use it in GitHub Desktop.
Gitlab上で特定のリポジトリ以下のissueを別リポジトリのissueへ移行するスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
import time | |
GITLAB_PRIVATE_TOKEN = 'token_hogehoge_token' | |
export_pj_id = 'numxxxx' | |
import_pj_id = 'numxxxx' | |
export_pj_url = f"https://gitlab.com/api/v4/projects/{export_pj_id}/issues?state=opened&private_token={GITLAB_PRIVATE_TOKEN}" | |
import_pj_url = f"https://gitlab.com/api/v4/projects/{import_pj_id}/issues?private_token={GITLAB_PRIVATE_TOKEN}" | |
headers = {'content-type': 'application/json'} | |
resp = requests.get(export_pj_url) | |
for issue in (json.loads(resp.content)): | |
payload = { | |
'id': issue['id'], | |
'iid': issue['iid'], | |
'title': issue['title'], | |
'description': issue['description'], | |
'created_at': issue['created_at'], | |
'assignee_ids': [i['id'] for i in issue['assignees']], | |
'created_at': issue['created_at'], | |
'due_date': issue['due_date'], | |
'labels': '', | |
} | |
r = requests.post(import_pj_url, data=json.dumps(payload), headers=headers) | |
print(r.text) | |
time.sleep(2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
payload's spec: https://docs.gitlab.com/ee/api/issues.html#new-issue
get issue spec: https://docs.gitlab.com/ee/api/issues.html#list-issues