1

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?

suryakrupa
  • 3,852
  • 1
  • 25
  • 34

1 Answers1

0

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.

suryakrupa
  • 3,852
  • 1
  • 25
  • 34