Executing bash and groovy commands on a Jenkins node

  1. Through the Script Console (Manage Jenkins -> Nodes -> Select a node -> Script Console) of the node we can execute groovy script
  2. Run the bash command ls -la on current directory:
    println "ls -la".execute().text
  3. Run the following command to get the IP address (groovy):
    println InetAddress.localHost.canonicalHostName
Note: possibly this requires whitelisting for security via In-process Script Approval