Jenkins API 实践

获取项目配置

curl -X GET http://admin:Jenkins@127.0.0.1:37555/job/geek-icem_backend_build-packages/config.xml

build

curl -X POST http://admin:Jenkins@127.0.0.1:37555/job/geek-icem_backend_build-packages/build -F ‘json={“parameter”: [{“name”: “Project”, “value”: “geek-icem-gateway”}, {“name”: “Branch”, “value”: “ad”}]}’

curl -X POST http://127.0.0.1:37555/job/geek-icem_backend_build-packages/build –user admin:Jenkins -H ‘cache-control: no-cache’ -F ‘json={“parameter”: [{“name”: “Project”, “value”: “geek-icem-gateway”}, {“name”: “Branch”, “value”: “ad”}]}’

获取构建信息

curl -X GET http://admin:Jenkins@127.0.0.1:37555/job/geek-icem_backend_build-packages/lastCompletedBuild/api/json

获取构建信息

curl -X GET http://admin:Jenkins@127.0.0.1:37555/job/geek-icem_backend_build-packages/lastBuild/api/json

获取控制台日志

curl -X GET http://admin:Jenkins@127.0.0.1:37555/job/geek-icem_backend_build-packages/17/consoleText

lastBuild, lastStableBuild, lastSuccessfulBuild, lastFailedBuild, lastUnstableBuild, lastUnsuccessfulBuild, lastCompletedBuild

获取描述

curl -X GET http://admin:Jenkins@127.0.0.1:37555/job/geek-icem_backend_build-packages/description

References

jenkins 出现“Error 403 No valid crumb was included in the request ”的解决方案

python-jenkins

使用 Python 操作 Git 版本库 - GitPython

Jenkins获取编译状态

GitPython Tutorial