From f86181b6205b6497e276e09ef6c7db7456a2cd87 Mon Sep 17 00:00:00 2001 From: vicu Date: Thu, 7 Dec 2023 15:55:42 +0100 Subject: [PATCH 1/2] feature: add launch method to Node class --- jenkinsapi/node.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/jenkinsapi/node.py b/jenkinsapi/node.py index 2c64cac0..71904c81 100644 --- a/jenkinsapi/node.py +++ b/jenkinsapi/node.py @@ -269,6 +269,29 @@ def set_offline(self, message="requested from jenkinsapi") -> None: % (data["offline"], data["temporarilyOffline"]) ) + def launch(self) -> None: + """ + Tries to launch a connection with the slave if it is currently + disconnected. Because launching a connection with the slave does not + mean it is online (a slave can be launched, but set offline), this + function does not check if the launch was successful. + """ + if not self._data["launchSupported"]: + raise AssertionError("The node does not support manually launch.") + + if not self._data["manualLaunchAllowed"]: + raise AssertionError( + "It is not allowed to manually launch this node." + ) + + url = ( + self.baseurl + "/launchSlaveAgent" + ) + html_result = self.jenkins.requester.post_and_confirm_status( + url, data={} + ) + log.debug(html_result) + def toggle_temporarily_offline( self, message="requested from jenkinsapi" ) -> None: From 9204b68b56f51f724ec43196a8cffdc72d545718 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 7 Dec 2023 15:50:42 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- jenkinsapi/node.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/jenkinsapi/node.py b/jenkinsapi/node.py index 71904c81..33b62cb2 100644 --- a/jenkinsapi/node.py +++ b/jenkinsapi/node.py @@ -284,9 +284,7 @@ def launch(self) -> None: "It is not allowed to manually launch this node." ) - url = ( - self.baseurl + "/launchSlaveAgent" - ) + url = self.baseurl + "/launchSlaveAgent" html_result = self.jenkins.requester.post_and_confirm_status( url, data={} )