Get the connected Jenkins master for a slave

tags: jenkins

Written on January 25, 2018

If you operate several Jenkins masters with dozens of slaves, you might end up one day on a slave without knowing to which master it is connected. In case the master establishes the connection to the slave, following snippet will help

JENKINS_MASTER_IP=$(netstat -plant | grep sshd | grep jenkins | tr -s ' ' | cut -d ' ' -f 5 | cut -d ':' -f 1)