What is the programmatic way to disconnect a node in Jenkins?

前端 未结 2 762
北恋
北恋 2021-01-15 04:52

I want to accomplish, through a script using the Jenkins API, the equivalent of manually clicking on the \"Disconnect\" link on the node management page in Jenkins. I want t

相关标签:
2条回答
  • 2021-01-15 05:02

    I don't see anything in the pipeline-model-definition-plugin regarding node management.

    So an alternative approach would be to call the disconnect action through the Jenkins API from the pipeline.

    • The Jenkins API for disconnect is:

      http://[jenkins_url]:8080/computer/[slave_name]/doDisconnect?offlineMessage=bye
      
    • Making a Jenkins API call from a pipeline is done through the JENKINS HTTP Request Plugin:

      def response = httpRequest "http://..."
      
    0 讨论(0)
  • 2021-01-15 05:20

    The hudson.model.Computer class has a disconnect(DisconnectReason) method

    Here are the docs for this

    In my case, I was able to acquire the Computer instance and disconnect by using Jenkins.instance.getNode(...).getComputer().disconnect(...)

    0 讨论(0)
提交回复
热议问题