[英]devpi: manually upload toxresult.json
I currently have a Jenkins pipeline which builds and tests my python package using tox .我目前有一个 Jenkins 管道,它使用tox构建和测试我的 python 包。 If all unittests pass, it will be uploaded to my local devpi index.
如果所有单元测试都通过,它将上传到我的本地 devpi 索引。
Using devpi test <mypackage>
I can attach the test results to the release file on the index.使用
devpi test <mypackage>
我可以将测试结果附加到索引上的发布文件。 But this will download the already built package again, repeat all of the already passed test suites defined in the tox.ini
file and only then upload the results in form of a toxresult.json
.但这将再次下载已经构建的包,重复在
tox.ini
文件中定义的所有已经通过的测试套件,然后才以toxresult.json
形式上传结果。
Is there any way to directly upload the toxresult.json
alongside the release files?有没有办法直接上传
toxresult.json
和发布文件? According to the quickstart and the documentation of test command there seems to be no command line option, and neither in the upload command.根据快速入门和测试命令的文档,似乎没有命令行选项, 上传命令中也没有。
Of course I could change my Jenkins pipeline to skip the tests before uploading and then build, upload and test the package using devpi.当然,我可以更改我的 Jenkins 管道以在上传之前跳过测试,然后使用 devpi 构建、上传和测试包。 If the
devpi test
command fails I can remove the package from the index.如果
devpi test
命令失败,我可以从索引中删除该包。 But I would rather not upload a package with failing tests in the first place.但我宁愿不首先上传测试失败的包。
It's relatively easy if you allow the anonymous user to upload test results (which is the default setting IIRC).如果您允许匿名用户上传测试结果(这是默认设置 IIRC),则相对容易。 Make a
POST
request to the URL of the uploaded dist, passing tox
results as JSON payload.向上传的 dist 的 URL 发出
POST
请求,将tox
结果作为 JSON 负载传递。 Example:例子:
$ curl -i \
-H "content-type: application/json" \
-X POST \
--data-binary "@/tmp/toxreport.json" \
http://my-server/myuser/myindex/+f/19b/d3544d03b1716/mypkg-1.0.tar.gz
On success, you should get a result similar to成功后,您应该得到类似于
HTTP/1.1 100 Continue
HTTP/1.1 200 OK
Content-Length: 143
Content-Type: application/json
Date: Wed, 08 Jan 2020 15:48:32 GMT
Server: waitress
X-Devpi-Api-Version: 2
X-Devpi-Master-Uuid: d800735d04a14c2d9bde920149cb8dbc
X-Devpi-Serial: 42
X-Devpi-Server-Version: 5.3.1
X-Devpi-Uuid: d800735d04a14c2d9bde920149cb8dbc
{
"result": "myuser/myindex/+f/19b/d3544d03b1716/mypkg-1.0.tar.gz.toxresult-20200108154832-0",
"type": "toxresultpath"
}
You can find the target URL in the File
column of the files table on the project page.您可以在项目页面上文件表的
File
列中找到目标 URL。 Or query the JSON API and filter the results, eg或者查询JSON API并过滤结果,例如
$ devpi getjson /myuser/myindex/mypkg | jq -r '[ .result[] | .["+links"][] | .href ]'
devpi
uses basic auth, so simply pass the base64-encoded credentials in the Authorization: Basic
header. devpi
使用基本身份验证,因此只需在Authorization: Basic
标头中传递 base64 编码的凭据即可。 Example, with curl
again:例如,再次使用
curl
:
$ curl -i \
--user myuser:mypass \
-H "content-type: application/json" \
-X POST \
--data-binary "@/tmp/toxreport.json" \
http://my-server/myuser/myindex/+f/19b/d3544d03b1716/mypkg-1.0.tar.gz
If you need details on the test upload authentication, check out my other answer here .如果您需要有关测试上传身份验证的详细信息,请在此处查看我的其他答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.