Jenkins-python-api
前言
Jenkins作为最流行的自动化流程的核心工具,我们使用它自带的web-ui完全可以满足日常的构建及发布工作,但是如果需要和其他系统做集成就必须二次开发或者通过API方式进行交互了。
Jenkins介绍及相关
python版本的API调用
目前python版本的API主要有两个第三方包
- JenkinsApi
- Python Jenkins
API示例
JenkinsAPi模块
1 | #! /usr/bin/env python |
Some API
This module is a collection of helpful, high-level functions for automating common tasks. Many of these functions were designed to be exposed to the command-line, hence they have simple string arguments.
1 | from jenkinsapi import api as API |
Python Jenkins模块
Working with Jenkins Jobs
This is an example showing how to create, configure and delete Jenkins jobs.
1 | #! /usr/bin/env python |
Working with Jenkins Views
This is an example showing how to create, configure and delete Jenkins views.
1 | # 试图相关 |
总结
建议使用Python Jenkins模块,相对JenkinsApi而言,模块封装的更好。接口调用更方便,更容易上手,模块内容不是很多,可以自己研读源码进行二次开发,方便与其他系统集成,更好的落地DevOps方案的实施;