问题描述
我需要从Python脚本访问Jenkins JSON API.问题在于我们的Jenkins安装是安全的,因此登录用户必须选择一个证书.遗憾的是,在Jenkins 远程访问文档中,他们没有提到关于证书的事情,我尝试使用API令牌没有成功.
I need to access the Jenkins JSON API from a Python script. The problem is that our Jenkins installation is secured so to log in users have to select a certificate. Sadly, in Jenkins Remote Access Documentation they don't mention a thing about certificates and I tried using the API Token without success.
如何从Python脚本进行身份验证以使用其JSON API?
How can I get to authenticate from a Python script to use their JSON API?
提前谢谢!
推荐答案
您必须使用HTTP基本身份验证向JSON API进行身份验证.
You have to authenticate to the JSON API using HTTP Basic Auth.
https://wiki.jenkins-ci.org/display/JENKINS/Authenticating + scripted +客户
这里是将Basic Auth与Python结合使用的示例.
Here is a sample of using Basic Auth with Python.
http://docs.python-requests.org/en/master /user/authentication/
请记住,如果您在内部Jenkin服务器上使用自签名证书,则需要关闭证书验证 OR ,从服务器获取证书并将其添加到HTTP请求中
Keep in mind if you are using a Self Signed certificate on an internal Jenkin Server you'll need to turn off certificate validation OR get the certificate from the server and add it to the HTTP request
http://docs.python-requests.org/en/master /user/advanced/
这篇关于在远程访问其JSON API时如何在Jenkins中进行身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!