Home > OS >  IS there any process to automate the jeniks nodes/slaves
IS there any process to automate the jeniks nodes/slaves

Time:10-19

We have Jenkin nodes. They occasionally lose connection. When we need to bring them back online. We're going to manually reset the nodes. Is there a method to automate it without using plugins?

CodePudding user response:

What OS do these nodes have? And what does "losing connection" mean? If your nodes are Windows, and if loosing connection refers to your VMs shutting down, then you can install Jenkins node connection as a service, so that they automatically start when your VM restarts. If your nodes are in Linux, then you can get the nodes to automatically start up with scripts. If your nodes randomly lose connection for some other reason, then it's better to figure out why the nodes lose connection and fix that instead of just starting up the connections once they shut down. Consider this answer and see if that helps.

CodePudding user response:

Ideally, the nodes should reconnect once availabe. If they are going to an offline state. You should be able to use a script like below to bring them up. In the following script, temporarily disabled nodes are brought online.

import hudson.slaves.OfflineCause.UserCause

def jenkinsNodes = Jenkins.instance.getNodes()
  for(def node: jenkinsNodes) {
      if (node.getComputer().isTemporarilyOffline()){  
           println(node.getComputer().class)
           UserCause cause =  new UserCause(User.current(), "This is a automated process!!")
           node.getComputer().setTemporarilyOffline(false, cause)
      }
  }
  • Related