Skip to main content

jenkins pylint api.

Project description

lintjenkins

https://img.shields.io/pypi/v/lintjenkins.svg https://img.shields.io/travis/510908220/lintjenkins.svg Documentation Status Updates

lintjenkins 是干什么的? 这里举一个使用场景的例子. 我又一个django项目需要使用jenkins进行持续代码检查, 需要做的操作是:

  1. 在jenkins上创建一个job, 配置job 和violations等信息.

  2. 在配置job时,添加svn代码时,需要输入账号和密码进行验证

  3. 查看检查结果

  4. 当需要统计历史结果时, 只能手动去看一次次检查结果.

lintjenkins 就是将上述场景操作封装为接口,便于二次开发.

Require

  1. 目标机器装有jenkins+violations

  2. 被检查的python代码所在目录符合包的形式,如:

    • __init__.py

    • requirements.txt

    • pylint.cfg

  3. 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
             }
         ]
     }

字段说明:

filed.png

对应的在jenkins上的表现是:

lintjenkins.png

注意

  • 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lintjenkins-0.1.13.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

lintjenkins-0.1.13-py2.py3-none-any.whl (11.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file lintjenkins-0.1.13.tar.gz.

File metadata

  • Download URL: lintjenkins-0.1.13.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for lintjenkins-0.1.13.tar.gz
Algorithm Hash digest
SHA256 fcb7f5ae0ae2c9a29d71cd78917861043c04d1430c1fe5124ad9d432518af9c2
MD5 200ba250cdca345163ece1a4d45d0079
BLAKE2b-256 aa4386c9c349a869a371ce007919322eb8340593f41d4c0d104edd8bb3ba1145

See more details on using hashes here.

File details

Details for the file lintjenkins-0.1.13-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for lintjenkins-0.1.13-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 609c7b1a4d64511475eab5544da75bf80e40aadd0b079891b5df41c515db9f0d
MD5 a225913a7de190bf033a1ec403de0edf
BLAKE2b-256 42d14e00c21d41428fab3a7ef8c7f4003bf46503c02a3adbf5616e0ca127b7f5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page