-
-
Notifications
You must be signed in to change notification settings - Fork 501
Fixes and improvements #864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 9 commits
af5086c
08bb79b
62bb63e
aa5c713
1b91b2c
6832c31
fcd36cc
51a8e30
3a3c3e4
f330e0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,9 +46,20 @@ def check_updates_server(self) -> None: | |
|
||
@property | ||
def update_center_dict(self): | ||
update_center = "https://updates.jenkins.io/update-center.json" | ||
jsonp = requests.get(update_center).content.decode("utf-8") | ||
return json.loads(jsonp_to_json(jsonp)) | ||
if not hasattr(self, "_update_center_dict"): | ||
update_center = ( | ||
"https://updates.jenkins.io/update-center.actual.json" | ||
) | ||
self._update_center_dict = requests.get(update_center).json() | ||
return self._update_center_dict | ||
|
||
@property | ||
def update_center_dict_server(self): | ||
if not hasattr(self, "_update_center_dict_server"): | ||
self._update_center_dict_server = self.jenkins_obj.requester.get_url( | ||
self.jenkins_obj.get_update_center_url(2) | ||
).json() | ||
return self._update_center_dict_server | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am concerned about this part, and anywhere I added caching. as it may have impact on code that uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When in doubt, lets add more tests I'll take another look when I have time There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll have some time to look into tests. I had to add another method in |
||
|
||
def _poll(self, tree=None): | ||
return self.get_data(self.baseurl, tree=tree) | ||
|
@@ -145,16 +156,11 @@ def _install_specific_version(self, plugin: "Plugin") -> None: | |
download_link: str = plugin.get_download_link( | ||
update_center_dict=self.update_center_dict | ||
) | ||
downloaded_plugin: BytesIO = self._download_plugin(download_link) | ||
plugin_dependencies = self._get_plugin_dependencies(downloaded_plugin) | ||
log.debug("Installing dependencies for plugin '%s'", plugin.shortName) | ||
self.jenkins_obj.install_plugins(plugin_dependencies) | ||
url = "%s/pluginManager/uploadPlugin" % self.jenkins_obj.baseurl | ||
requester = self.jenkins_obj.requester | ||
downloaded_plugin.seek(0) | ||
requester.post_and_confirm_status( | ||
url, | ||
files={"file": ("plugin.hpi", downloaded_plugin)}, | ||
files={"filename": plugin.shortName, "pluginUrl": download_link}, | ||
data={}, | ||
params={}, | ||
) | ||
|
@@ -209,6 +215,24 @@ def _plugin_has_finished_installation(self, plugin) -> bool: | |
except JenkinsAPIException: | ||
return False # lack of update_center in Jenkins 1.X | ||
|
||
def _plugins_has_finished_installation(self) -> bool: | ||
""" | ||
Return True if installation is marked as 'Success' or | ||
'SuccessButRequiresRestart' in Jenkins' update_center, | ||
else return False. | ||
""" | ||
try: | ||
jobs = self.update_center_install_status["data"]["jobs"] | ||
for job in jobs: | ||
if job["installStatus"] not in [ | ||
"Success", | ||
"SuccessButRequiresRestart", | ||
]: | ||
return False | ||
return True | ||
except JenkinsAPIException: | ||
return False # lack of update_center in Jenkins 1.X | ||
|
||
def plugin_version_is_being_installed(self, plugin) -> bool: | ||
""" | ||
Return true if plugin is currently being installed. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is causing a test failure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=========================== short test summary info ============================
FAILED jenkinsapi_tests/unittests/test_plugins.py::TestPlugins::test_plugin_repr - AssertionError: '<jenkinsapi.plugin.Plugin subversion@Unknown>' != '<jenkinsapi.plugin.Plugin subversion>'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the test