python-jenkins使用

 

安装: pip3 install python-jenkins lxml Beautifulsoup4

    jenkins_server_url = 'http://192.168.24.191:8080/jenkins/'
    user_id = 'testuser'
    api_token = '7ca1a78d7eb1149137d432c4cf3aaeb3' #也可以直接使用密码
    server = jenkins.Jenkins(jenkins_server_url, username=user_id, password=api_token)

 

 

使用手册:

https://www.systutorials.com/docs/linux/man/1-pythonjenkins/

api: https://python-jenkins.readthedocs.io/en/latest/api.html#jenkins.Jenkins.reconfig_node

功能列表:https://python-jenkins.readthedocs.io/en/latest/

 

 

Example 2: Logging into Jenkins using kerberos

Kerberos support is only enabled if you have “kerberos” python package installed. You can install the “kerberos” package from PyPI using the obvious pip command.

pip install kerberos

Note

This might require python header files as well as kerberos header files.

If you have “kerberos” python package installed, python-jenkins tries to authenticate using kerberos automatically when the Jenkins server replies “401 Unauthorized” and indicates it supports kerberos. That is, kerberos authentication should work automagically. For a quick test, just try the following.

import jenkins

server = jenkins.Jenkins('http://localhost:8080')
print server.jobs_count()
posted @ 2022-04-26 14:08  i舒  阅读(194)  评论(0编辑  收藏  举报