Plugins
Plugins
Install a plugin
- plugins.Plugins.install()
Installs a plugin in Jenkins.
- Parameters:
- Returns:
A JenkinsActionObject representing the installation action.
- Return type:
- Raises:
JenkinsGeneralException – If a general exception occurs.
Example plugin: https://plugins.jenkins.io/pipeline-stage-view/
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
print(jenkins.plugins.install("pipeline-stage-view", 2.18))
The above code will output:
request=<Request object at 2898119135520> content='[200] Successfully installed plugin (pipeline-stage-view).' status_code=200
Upload a plugin
- plugins.Plugins.upload()
Uploads a plugin to Jenkins.
- Parameters:
- Returns:
A JenkinsActionObject representing the upload action.
- Return type:
- Raises:
JenkinsGeneralException – If a general exception occurs.
Example plugin: https://plugins.jenkins.io/chucknorris/
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
filename = "chucknorris.hpi"
with open(f"C:\\Users\\UnknownUser\\Downloads\\{filename}", "rb") as file:
print(jenkins.plugins.upload(filename, file))
The above code will output:
request=<Request object at 2188075571200> content='[200] Successfully uploaded plugin (chucknorris.hpi).' status_code=200
Available
Search for an available plugin (A plugin that is not already installed)
The plugin ID/Name is found in the plugin docs ‘ID’ field In the below link you will see ID: blueocean-rest https://plugins.jenkins.io/blueocean-rest/
- plugins.PluginGroup.search()
Search for a plugin or an installed plugin within the plugin group.
- Parameters:
- Returns:
A Plugin or Installed object representing the found plugin.
- Return type:
Union[jenkins_pysdk.plugins.Plugin, jenkins_pysdk.plugins.Installed]
- Raises:
JenkinsNotFound – If the plugin with the specified name is not found.
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
print(jenkins.plugins.available.search("blueocean-rest"))
The above code will output:
<jenkins_pysdk.plugins.Plugin object at 0x000001AB664C0370>
Iterate all available plugins
- plugins.PluginGroup.iter()
Iterate over the plugins or installed plugins within the plugin group.
- Parameters:
- Returns:
A generator that yields Plugin or Installed objects.
- Return type:
Generator[Union[jenkins_pysdk.plugins.Plugin, jenkins_pysdk.plugins.Installed]]
- Raises:
JenkinsGeneralException – If a general exception occurs.
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
for plugin in jenkins.plugins.available.iter(_paginate=500):
print(plugin.name, plugin.version)
The above code will output:
pipeline-rest-api 2.34
pipeline-stage-view 2.34
jdk-tool 73.vddf737284550
command-launcher 107.v773860566e2e
jsch 0.2.16-86.v42e010d9484b_
sshd 3.322.v159e91f6a_550
authentication-tokens 1.53.v1c90fd9191a_b_
javadoc 243.vb_b_503b_b_45537
<truncated...>
List all available plugins
- plugins.PluginGroup.list()
List the plugins or installed plugins within the plugin group.
- Parameters:
_paginate (int, optional) – The number of items to paginate. Default is 0.
- Returns:
A list of Plugin or Installed objects.
- Return type:
List[Union[jenkins_pysdk.plugins.Plugin, jenkins_pysdk.plugins.Installed]]
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
print(jenkins.plugins.available.list(_paginate=1000))
The above code will output:
[<jenkins_pysdk.plugins.Plugin object at 0x000002316EB50520>, <jenkins_pysdk.plugins.Plugin object at 0x000002316EB50130>, <jenkins_pysdk.plugins.Plugin object at 0x000002316EB50160>, <truncated...>]
Updates
Search for a plugin needing an update
The plugin ID/Name is found in the plugin docs ‘ID’ field In the below link you will see ID: ssh-credentials https://plugins.jenkins.io/ssh-credentials/
- plugins.PluginGroup.search()
Search for a plugin or an installed plugin within the plugin group.
- Parameters:
- Returns:
A Plugin or Installed object representing the found plugin.
- Return type:
Union[jenkins_pysdk.plugins.Plugin, jenkins_pysdk.plugins.Installed]
- Raises:
JenkinsNotFound – If the plugin with the specified name is not found.
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
print(jenkins.plugins.updates.search("ssh-credentials").name)
The above code will output:
ssh-credentials
Iterate all plugins needing an updates
- plugins.PluginGroup.iter()
Iterate over the plugins or installed plugins within the plugin group.
- Parameters:
- Returns:
A generator that yields Plugin or Installed objects.
- Return type:
Generator[Union[jenkins_pysdk.plugins.Plugin, jenkins_pysdk.plugins.Installed]]
- Raises:
JenkinsGeneralException – If a general exception occurs.
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
for plugin in jenkins.plugins.updates.iter(_paginate=500):
print(plugin.name, plugin.version, plugin.url)
The above code will output:
checks-api 2.2.0 https://updates.jenkins.io/download/plugins/checks-api/2.2.0/checks-api.hpi
github-branch-source 1787.v8b_8cd49a_f8f1 https://updates.jenkins.io/download/plugins/github-branch-source/1787.v8b_8cd49a_f8f1/github-branch-source.hpi
gradle 2.11 https://updates.jenkins.io/download/plugins/gradle/2.11/gradle.hpi
ionicons-api 70.v2959a_b_74e3cf https://updates.jenkins.io/download/plugins/ionicons-api/70.v2959a_b_74e3cf/ionicons-api.hpi
jackson2-api 2.17.0-379.v02de8ec9f64c https://updates.jenkins.io/download/plugins/jackson2-api/2.17.0-379.v02de8ec9f64c/jackson2-api.hpi
<truncated...>
List all plugins needing an updates
- plugins.PluginGroup.list()
List the plugins or installed plugins within the plugin group.
- Parameters:
_paginate (int, optional) – The number of items to paginate. Default is 0.
- Returns:
A list of Plugin or Installed objects.
- Return type:
List[Union[jenkins_pysdk.plugins.Plugin, jenkins_pysdk.plugins.Installed]]
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
print(jenkins.plugins.updates.list(_paginate=500))
The above code will output:
[<jenkins_pysdk.plugins.Plugin object at 0x000001CF357C4B20>, <truncated...>]
Installed
Search for an installed plugin
The plugin ID/Name is found in the plugin docs ‘ID’ field In the below link you will see ID: ssh-credentials https://plugins.jenkins.io/ssh-credentials/
- plugins.PluginGroup.search()
Search for a plugin or an installed plugin within the plugin group.
- Parameters:
- Returns:
A Plugin or Installed object representing the found plugin.
- Return type:
Union[jenkins_pysdk.plugins.Plugin, jenkins_pysdk.plugins.Installed]
- Raises:
JenkinsNotFound – If the plugin with the specified name is not found.
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
print(jenkins.plugins.installed.search("ant").version)
The above code will output:
497.v94e7d9fffa_b_9
Iterate all installed plugins
- plugins.PluginGroup.iter()
Iterate over the plugins or installed plugins within the plugin group.
- Parameters:
- Returns:
A generator that yields Plugin or Installed objects.
- Return type:
Generator[Union[jenkins_pysdk.plugins.Plugin, jenkins_pysdk.plugins.Installed]]
- Raises:
JenkinsGeneralException – If a general exception occurs.
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
for plugin in jenkins.plugins.installed.iter(_paginate=500):
print(plugin.name, plugin.active)
The above code will output:
ant True
antisamy-markup-formatter True
apache-httpcomponents-client-4-api True
bootstrap5-api True
bouncycastle-api True
<truncated...>
List all installed plugins
- plugins.PluginGroup.list()
List the plugins or installed plugins within the plugin group.
- Parameters:
_paginate (int, optional) – The number of items to paginate. Default is 0.
- Returns:
A list of Plugin or Installed objects.
- Return type:
List[Union[jenkins_pysdk.plugins.Plugin, jenkins_pysdk.plugins.Installed]]
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
print(jenkins.plugins.updates.list(_paginate=500))
The above code will output:
[<jenkins_pysdk.plugins.Installed object at 0x0000021DBB290A30>, <truncated...>]
UpdateCenter
Search for a site
- plugins.UpdateCenter.search()
Search for a site by name.
- Parameters:
name (str) – The name of the site to search for.
- Returns:
The Site object if found, otherwise raise an exception.
- Return type:
- Raises:
JenkinsNotFound – If the site with the specified name is not found.
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
print(jenkins.plugins.sites.search("default"))
The above code will output:
<jenkins_pysdk.plugins.Site object at 0x00000230D4BD1D20>
Iterate all sites
- plugins.UpdateCenter.iter()
Iterate over the sites in the update center.
- Returns:
A generator yielding Site objects.
- Return type:
Generator[
jenkins_pysdk.plugins.Site]- Raises:
JenkinsGeneralException – If a general exception occurs.
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
for site in jenkins.plugins.sites.iter():
print(site.id)
The above code will output:
default
List all sites
- plugins.UpdateCenter.list()
Get a list of all sites in the update center.
- Returns:
A list of Site objects.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
print(jenkins.plugins.sites.search("default"))
The above code will output:
[<jenkins_pysdk.plugins.Site object at 0x0000027AA7115D20>]
Add a new update center
List all sites
- plugins.UpdateCenter.create()
Create a new site in the update center.
- Returns:
JenkinsActionObject representing the create update center operation.
- Return type:
- Raises:
JenkinsGeneralException – If a general exception occurs.
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
print(jenkins.plugins.sites.create("https://www.google.com/update-center.json"))
The above code will output:
request=<Request object at 1985835210512> content='[200] Successfully added update center (https://www.google.com/update-center.json).' status_code=200
Plugin
Available
Get the available plugin name
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
av = jenkins.plugins.availables.search("pipeline-stage-view")
print(av.name)
The above code will output:
pipeline-stage-view
Get the available plugin version
- plugins.Plugin.version()
The version of the plugin.
- Returns:
The version of the plugin.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
av = jenkins.plugins.availables.search("pipeline-stage-view")
print(av.version)
The above code will output:
2.34
Get the available plugin URL
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
av = jenkins.plugins.availables.search("pipeline-stage-view")
print(av.url)
The above code will output:
https://updates.jenkins.io/download/plugins/pipeline-stage-view/2.34/pipeline-stage-view.hpi
Check if the available plugin is compatible
- plugins.Plugin.compatible()
Indicates whether the plugin is compatible.
- Returns:
True if the plugin is compatible, False otherwise.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
av = jenkins.plugins.availables.search("pipeline-stage-view")
print(av.compatible)
The above code will output:
True
Get the available plugin dependencies
- plugins.Plugin.dependencies()
The dependencies of the plugin.
- Returns:
A list of dictionaries representing the dependencies, where each dictionary contains the dependency name as key and the dependency version as value.
- Return type:
List[dict]
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
av = jenkins.plugins.availables.search("pipeline-stage-view")
print(av.dependencies)
The above code will output:
[{'workflow-api': '1213.v646def1087f9'}, {'pipeline-rest-api': '2.34'}, {'workflow-job': '1295.v395eb_7400005'}]
Get the available plugin required core version
- plugins.Plugin.requires()
The required core version for the plugin.
- Returns:
The required core version for the plugin.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
av = jenkins.plugins.availables.search("pipeline-stage-view")
print(av.requires)
The above code will output:
2.361.4
Get the available plugin docs page
- plugins.Plugin.docs()
The documentation URL for the plugin.
- Returns:
The documentation URL for the plugin.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
av = jenkins.plugins.availables.search("pipeline-stage-view")
print(av.docs)
The above code will output:
https://plugins.jenkins.io/pipeline-stage-view
Get the update centre of the available plugin
- plugins.Plugin.site()
The site associated with the plugin.
- Returns:
The Site object representing the site associated with the plugin.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
av = jenkins.plugins.availables.search("pipeline-stage-view")
print(av.site.url)
The above code will output:
https://updates.jenkins.io/update-center.json
Installed
Get the installed plugin name
- plugins.Installed.name()
The name of the installed plugin.
- Returns:
The name of the installed plugin.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
ins = jenkins.plugins.installed.search("maven-plugin")
print(ins.name)
The above code will output:
maven-plugin
Get the active status of the installed plugin
- plugins.Installed.active()
Indicates whether the plugin is active.
- Returns:
True if the plugin is active, False otherwise.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
ins = jenkins.plugins.installed.search("maven-plugin")
print(ins.active)
The above code will output:
True
Enable the installed plugin
- plugins.Installed.enable()
Enable the installed plugin.
- Returns:
JenkinsActionObject representing the enable action.
- Return type:
- Raises:
JenkinsGeneralException – If a general exception occurs.
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
ins = jenkins.plugins.installed.search("maven-plugin")
print(ins.enable())
The above code will output:
request=<Request object at 1991094649216> content='[200] Successfully enabled plugin (maven-plugin).' status_code=200
Disable the installed plugin
- plugins.Installed.disable()
Disable the installed plugin.
- Returns:
JenkinsActionObject representing the disable action.
- Return type:
- Raises:
JenkinsGeneralException – If a general exception occurs.
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
ins = jenkins.plugins.installed.search("maven-plugin")
print(ins.disable())
The above code will output:
request=<Request object at 2529251115152> content='[200] Successfully disabled plugin (maven-plugin).' status_code=200
Get the installed plugin version
- plugins.Installed.version()
The version of the installed plugin.
- Returns:
The version of the installed plugin.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
ins = jenkins.plugins.installed.search("maven-plugin")
print(ins.version)
The above code will output:
3.23
Get the installed plugin URL
- plugins.Installed.url()
The URL of the installed plugin.
- Returns:
The URL of the installed plugin.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
ins = jenkins.plugins.installed.search("maven-plugin")
print(ins.url)
The above code will output:
https://plugins.jenkins.io/maven-plugin
Get the installed plugin dependencies
- plugins.Installed.dependencies()
The dependencies of the installed plugin.
- Returns:
A list of dictionaries representing the dependencies, where each dictionary contains the dependency name as key and the dependency version as value.
- Return type:
List[Dict]
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
ins = jenkins.plugins.installed.search("maven-plugin")
print(ins.dependencies)
The above code will output:
[{'optional': False, 'shortName': 'commons-lang3-api', 'version': '3.12.0-36.vd97de6465d5b_'}, {'optional': False, 'shortName': 'apache-httpcomponents-client-4-api', 'version': '4.5.14-150.v7a_b_9d17134a_5'}, {'optional': False, 'shortName': 'javadoc', 'version': '233.vdc1a_ec702cff'}, {'optional': False, 'shortName': 'jsch', 'version': '0.2.8-65.v052c39de79b_2'}, {'optional': False, 'shortName': 'junit', 'version': '1207.va_09d5100410f'}, {'optional': False, 'shortName': 'mailer', 'version': '457.v3f72cb_e015e5'}, {'optional': True, 'shortName': 'token-macro', 'version': '359.vb_cde11682e0c'}]
Get the installed plugin required core version
- plugins.Installed.requires()
The required core version for the installed plugin.
- Returns:
The required core version for the installed plugin.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
ins = jenkins.plugins.installed.search("maven-plugin")
print(ins.requires)
The above code will output:
2.387.3
Get the installed plugin pinned status
- plugins.Installed.pinned()
Indicates whether the installed plugin is pinned.
- Returns:
True if the plugin is pinned, False otherwise.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
ins = jenkins.plugins.installed.search("maven-plugin")
print(ins.requires)
The above code will output:
False
Delete the installed plugin
- plugins.Installed.delete()
Delete the plugin from the Jenkins instance.
- Returns:
JenkinsActionObject representing the delete action.
- Return type:
- Raises:
JenkinsGeneralException – If a general exception occurs.
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
ins = jenkins.plugins.installed.search("maven-plugin")
print(ins.delete())
The above code will output:
request=<Request object at 2148244816416> content='[200] Successfully uninstalled plugin (maven-plugin).' status_code=200
Updates
Get the update plugin name
- plugins.Plugin.name()
The name of the plugin.
- Returns:
The name of the plugin.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
up = jenkins.plugins.updates.search("checks-api")
print(up.name)
The above code will output:
checks-api
Get the update plugin version
- plugins.Plugin.version()
The version of the plugin.
- Returns:
The version of the plugin.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
up = jenkins.plugins.updates.search("checks-api")
print(up.version)
The above code will output:
2.2.0
Get the update plugin URL
- plugins.Plugin.url()
The URL of the plugin.
- Returns:
The URL of the plugin.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
up = jenkins.plugins.updates.search("checks-api")
print(up.url)
The above code will output:
https://updates.jenkins.io/download/plugins/checks-api/2.2.0/checks-api.hpi
Get the update plugin compatible status
- plugins.Plugin.compatible()
Indicates whether the plugin is compatible.
- Returns:
True if the plugin is compatible, False otherwise.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
up = jenkins.plugins.updates.search("checks-api")
print(up.compatible)
The above code will output:
True
Get the update plugin dependencies
- plugins.Plugin.dependencies()
The dependencies of the plugin.
- Returns:
A list of dictionaries representing the dependencies, where each dictionary contains the dependency name as key and the dependency version as value.
- Return type:
List[dict]
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
up = jenkins.plugins.updates.search("checks-api")
print(up.dependencies)
The above code will output:
[{'workflow-support': '865.v43e78cc44e0d'}, {'workflow-step-api': '657.v03b_e8115821b_'}, {'commons-lang3-api': '3.13.0-62.v7d18e55f51e2'}, {'commons-text-api': '1.11.0-95.v22a_d30ee5d36'}, {'plugin-util-api': '4.1.0'}, {'display-url-api': '2.200.vb_9327d658781'}]
Get the update plugin required core version
- plugins.Plugin.requires()
The required core version for the plugin.
- Returns:
The required core version for the plugin.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
up = jenkins.plugins.updates.search("checks-api")
print(up.requires)
The above code will output:
2.426.3
Get the update plugin docs page
- plugins.Plugin.docs()
The documentation URL for the plugin.
- Returns:
The documentation URL for the plugin.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
up = jenkins.plugins.updates.search("checks-api")
print(up.docs)
The above code will output:
https://plugins.jenkins.io/checks-api
Get the update plugin update centre site
- plugins.Plugin.site()
The site associated with the plugin.
- Returns:
The Site object representing the site associated with the plugin.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
up = jenkins.plugins.updates.search("checks-api")
print(up.site.url)
The above code will output:
https://updates.jenkins.io/update-center.json
Site
Get the update centre site ID
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
site = jenkins.plugins.sites.search("default")
print(site.id)
The above code will output:
default
Get the update centre site URL
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
site = jenkins.plugins.sites.search("default")
print(site.url)
The above code will output:
https://updates.jenkins.io/update-center.json
Check if the update centre has updates
- plugins.Site.has_updates()
Indicates whether the site has updates available.
- Returns:
True if updates are available, False otherwise.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
site = jenkins.plugins.sites.search("default")
print(site.has_updates)
The above code will output:
True
Get the plugin suggested url from the site
- plugins.Site.suggested_plugins_url()
The URL for suggested plugins for the site.
- Returns:
The URL for suggested plugins.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
site = jenkins.plugins.sites.search("default")
print(site.suggested_plugins_url)
The above code will output:
https://updates.jenkins.io/platform-plugins.json
Get the connection check url for the site
- plugins.Site.connection_check_url()
The URL for checking the connection of the site.
- Returns:
The URL for connection check.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
site = jenkins.plugins.sites.search("default")
print(site.connection_check_url)
The above code will output:
https://www.google.com/
Get the site data timestamp
- plugins.Site.timestamp()
The timestamp of the site data.
- Returns:
The timestamp of the site data.
- Return type:
from jenkins_pysdk.jenkins import Jenkins
jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608")
site = jenkins.plugins.sites.search("default")
print(site.timestamp)
The above code will output:
1713633892889