lintjenkins
lintjenkins 是干什么的? 这里举一个使用场景的例子. 我又一个django项目需要使用jenkins进行持续代码检查, 需要做的操作是:
在jenkins上创建一个job, 配置job 和violations等信息.
在配置job时,添加svn代码时,需要输入账号和密码进行验证
查看检查结果
当需要统计历史结果时, 只能手动去看一次次检查结果.
lintjenkins 就是将上述场景操作封装为接口,便于二次开发.
Free software: MIT license
Documentation: https://lintjenkins.readthedocs.io.
Require
目标机器装有jenkins+violations
被检查的python代码所在目录符合包的形式,如:
__init__.py
requirements.txt
pylint.cfg
pylint配置文件也需要修改.
没有配置可以使用`pylint –generate-rcfile > pylint.cfg`生成配置.
将`output-format`项的值改为`parseable`
init-hook`添加’import sys; sys.path.append(“/var/lib/jenkins/workspace/xxx”)’,`xxx`为jenkins job名. 否则会出现`W0403 Relative import ‘xxxx’警告
Example
In [2]: from lintjenkins import LintJenkins
In [3]: lint_jenkins = LintJenkins('http://x.x.x.x:8080', username='username', password='password')
In [4]: lint_jenkins.add_job(svn = 'svn', username='username', password='password',job_name='aliyun')
In [7]: lint_jenkins.get_build_numbers('aliyun')
Out[7]: [2, 1]
In [8]: lint_jenkins.get_build_info('aliyun',2)
Out[8]:
{
"violation_info": {
"violation_num": 2027,
"violation_file_num": 80
},
"commits": [
{
"msg": "svn提交信息",
"paths": [
{
"editType": "add",
"file": "新增的文件"
},
{
"editType": "edit",
"file": "编辑的文件"
}
],
"revision": 18830,
"datetime": "2017-06-12 09:44:38",
"author": "huzhongzhong"
}
],
"datetime": "2017-06-12 09:55:13",
"result_url":'http://x.x.x.x:8080/job/job_name/7/violations/'
"result": "UNSTABLE",
"duration": 49,
"revisions": [
{
"module": "svn地址",
"revision": 18830
}
]
}
字段说明:
对应的在jenkins上的表现是:
注意
Credentials Plugin`使用的是版本`2.1.16
如果报错`403 no valid crumb was included in the request , 简单可以这样处理:`setup jenkins’s “global security settings”: Uncheck “Prevent Cross Site Request Forgery exploits”
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
History
0.1.0 (2017-06-11)
First release on PyPI.
Metadata
Release files for lintjenkins 0.1.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lintjenkins-0.1.13.tar.gz | 19.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lintjenkins-0.1.13-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 30.4 kB
Release files / lintjenkins-0.1.13.tar.gz
| Download URL | lintjenkins-0.1.13.tar.gz |
|---|---|
| Size | 19.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fcb7f5ae0ae2c9a29d71cd78917861043c04d1430c1fe5124ad9d432518af9c2
|
|
BLAKE2b-256 checksum How to use checksums |
aa4386c9c349a869a371ce007919322eb8340593f41d4c0d104edd8bb3ba1145
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / lintjenkins-0.1.13-py2.py3-none-any.whl
| Download URL | lintjenkins-0.1.13-py2.py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
609c7b1a4d64511475eab5544da75bf80e40aadd0b079891b5df41c515db9f0d
|
|
BLAKE2b-256 checksum How to use checksums |
42d14e00c21d41428fab3a7ef8c7f4003bf46503c02a3adbf5616e0ca127b7f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |