我们正在尝试为Github中的特定提交创建标签。我们正在使用Github企业版。
下面是我尝试的代码:
import requests
headers = {"Authorization": "token my_token","Content-Type":"application/json"}
tag_url = "https://hostname/api/v3/repos/mohit/test-project/git/tags"
data_dict = {'tag': 'release_2018-02-09-535370b-123-testing',
'message': 'Testing tagging code','object': '3071bec06075e0fae98824d127b8d529febf3df5','type': 'commit'}
repo_list = requests.post(tag_url, headers=headers, json=data_dict)
print(repo_list.status_code)
release_url = "https://hostname/api/v3/repos/mohit/test-project/releases"
data_dict_1 = {"tag_name": "release_2018-02-09-535370b-123-testing", "target_commitish": '3071bec06075e0fae98824d127b8d529febf3df5',"name": "release_2018-02-09-535370b-123-testing", "body": "Testing tagging code","draft": False, "prerelease": False}
repo_list_1 = requests.post(release_url, headers=headers, json=data_dict_1)
print(repo_list_1.status_code)
参考了documentation,但不确定是否也是在Github企业中创建标签的方法。
在上面的代码中,状态代码为404。 需要有关如何使用python和Github API在Github Enterprise中为提交创建标签的帮助。