1
我需要將我的自定義Jenkins插件my-plugin.hpi
測試到一組Jenkins服務器。如何使用Python腳本將我的自定義Jenkins插件上載到Jenkins服務器
如何使用說Python腳本來做到最好?
我需要將我的自定義Jenkins插件my-plugin.hpi
測試到一組Jenkins服務器。如何使用Python腳本將我的自定義Jenkins插件上載到Jenkins服務器
如何使用說Python腳本來做到最好?
以下Python腳本使用requests
模塊和Jenkins
HTTP API來執行相同的操作。
import requests
ciUrl = 'https://jenkins-server-url/my-ci-name'
files = {'file': open('my-plugin.hpi', 'rb')}
headers = {'Authorization':'Basic <base-64-encodeder-username-password>'}
### Uploading the HPI plugin file
r = requests.post(ciUrl + "/pluginManager/uploadPlugin", files=files, headers=headers, verify=False)
### Safe Restart the Jenkins to ensure plugin is installed.
r = requests.post(ciUrl + "/safeRestart", headers=headers, verify=False)
打印(r.text)
注 驗證=假確保SSL驗證被關閉。如果您正在訪問未知的Jenkins服務器,請設置verify = True。