Gitlab-Python API。创建先生后,无法获得实际的MR状态信息
我用Python-Gitlab创建MR。创建后,我需要检查MR_CONFLICT和管道状态。
project = gl.projects.get(PROJECT_ID, lazy=False)
create_mr = project.mergerequests.create({'id': PROJECT_ID,
'title': 'Testing multiMR',
'source_branch': SOURCE_BRANCH,
'target_branch': TARGET_BRANCH,
'labels': [LABEL]})
mr_iid = getattr(create_mr, 'iid')
time.sleep(3)
get_mr = project.mergerequests.get(mr_iid)
mr_conflict = getattr(get_mr, 'has_conflicts')
mr_pipeline = getattr(get_mr, 'pipeline', 'No pipeline')
但是我没有获得此请求的实际信息!我的答案是像现在创建了MR这样的数据,并且没有有关Coflicts或管道的信息。
同时,如果我仅从不同的控制台启动另一个脚本以检查MR状态,则我获得了正确的实际信息。
另一个时刻。如果在具有MR Creation的脚本中,我运行周期
n = 4
while n > 0:
time.sleep(1)
n -= 1
project.refresh()
get_mr = project.mergerequests.get(mr_iid)
mr_conflict = get_mr.has_conflicts
mr_pipeline = getattr(get_mr, 'pipeline', 'No pipeline')
仍然没有更新的信息。
如何获取有关MR Inside脚本的实际信息?
Im creating MR with python-gitlab. After creation i need to check for mr_conflicts and pipeline state.
project = gl.projects.get(PROJECT_ID, lazy=False)
create_mr = project.mergerequests.create({'id': PROJECT_ID,
'title': 'Testing multiMR',
'source_branch': SOURCE_BRANCH,
'target_branch': TARGET_BRANCH,
'labels': [LABEL]})
mr_iid = getattr(create_mr, 'iid')
time.sleep(3)
get_mr = project.mergerequests.get(mr_iid)
mr_conflict = getattr(get_mr, 'has_conflicts')
mr_pipeline = getattr(get_mr, 'pipeline', 'No pipeline')
But I dont get actual info with this requests! I have answer with data like MR was created just now and has no info about coflicts or pipelines.
Same time if i start another script from different console only for checking MR status i got right actual information.
Another moment. If in the script with MR creation i run cycle
n = 4
while n > 0:
time.sleep(1)
n -= 1
project.refresh()
get_mr = project.mergerequests.get(mr_iid)
mr_conflict = get_mr.has_conflicts
mr_pipeline = getattr(get_mr, 'pipeline', 'No pipeline')
still no updated info.
How can i get actual info about MR inside script?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MR对象的属性不会刷新/自行更新。您必须再次使用API请求信息(创建一个新对象)
The attributes of an MR object will not refresh/update themselves. You must request the information with the API again (create a new object)