如何使用 ZenHub API 设置问题管道 [英] How to set an issue pipeline with ZenHub API

查看:27
本文介绍了如何使用 ZenHub API 设置问题管道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在企业 GitHub 安装中使用 ZenHub.我正在编写一个脚本来将问题从一个 GitHub 存储库移动到另一个,包括 ZenHub 信息.我已经复制了问题,设置了标签和里程碑.然后我使用 ZenHub API 来设置估计并创建史诗.一切正常.我的最后一步是将问题分配给 ZenHub 管道.以下工作正常(获取有关问题的信息):

We use ZenHub with our enterprise GitHub installation. I'm writing a script to move issues from one GitHub repo to another, including the ZenHub info. I've gotten the issues copied, labels and milestones set. I then use the ZenHub API to set estimates and create epics. All that works fine. My final step is to assign the issues to ZenHub pipelines. The following works fine (to get info about an issue):

zenhub_headers = {"X-Authentication-Token": "%s" % zenhub_token}
url = '%s/p1/repositories/%d/issues/15' % (zenhub_endpoint, repo)
response = requests.get(url, headers=zenhub_headers, verify=False)

但是,当我尝试将相同的问题移至具有以下内容的管道时:

However, when I attempt to move the same issue to a pipeline with the following:

params = json.dumps({"pipeline_id": "5a36d8584b9b9e57bc9729f9"} )
zenhub_headers = {"X-Authentication-Token": "%s" % zenhub_token}
url = '%s/p1/repositories/%d/issues/15/moves' % (zenhub_endpoint, repo)
response = requests.post(url, headers=zenhub_headers, data=params, verify=False)

我得到一个 400:b'{"message":"Invalid Field for pipeline_id: undefined"}'.我已经验证目标仓库中确实存在管道 5a36d8584b9b9e57bc9729f9.

I get a 400 with: b'{"message":"Invalid Field for pipeline_id: undefined"}'. I've verified that pipeline 5a36d8584b9b9e57bc9729f9 does exist in the target repo.

API 仍处于测试阶段.我想知道这是 API 中的错误还是我做错了什么.

The API is still in a beta state. I'm wondering if this is a bug in the API or something I'm doing wrong.

推荐答案

来自 ZenHub 的 Pablo 在这里.这里的问题是请求的格式不正确.position 参数缺失,不需要将请求体编码为字符串,直接发送字典即可:

Pablo from ZenHub here. The problem here is that the request is not well-formed. The position parameter is missing, and you don’t need to encode the request body as a string, you can just send the dictionary directly:

import requests

# No need to stringify
params = {
    "pipeline_id": "5a36d8584b9b9e57bc9729f9",
    "position": "top"
}

# some code omitted here...

response = requests.post(url, headers=zenhub_headers, data=params, verify=False)

移动问题端点的文档可在此处获得.干杯,

The documentation of the move issues endpoint is available here. Cheers,

这篇关于如何使用 ZenHub API 设置问题管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆