I need to test my custom Jenkins Plug-in my-plugin.hpi
to a set of Jenkins Servers.
How best can I do it using say a Python Script?
I need to test my custom Jenkins Plug-in my-plugin.hpi
to a set of Jenkins Servers.
How best can I do it using say a Python Script?
Following Python script uses requests
module and Jenkins
HTTP APIs to perform the same.
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)
print(r.text)
NOTE verify=False ensure SSL Validation is turned off. If you are accessing an-unknown Jenkins server, please set verify=True.