Skip to content

Instantly share code, notes, and snippets.

@nicc777
Last active April 29, 2022 12:34
Show Gist options
  • Save nicc777/974c37bf34c985c56db51ebeb28a80a7 to your computer and use it in GitHub Desktop.
Save nicc777/974c37bf34c985c56db51ebeb28a80a7 to your computer and use it in GitHub Desktop.
Groovy: Script to run from Jenkins Script Console to Quickly Test DNS to GitHub
import java.net.InetAddress;
import java.net.UnknownHostException;
void displayStuff(String whichHost, InetAddress inetAddress) {
print("--------------------------" + "\n");
print("Which Host:" + whichHost + "\n");
print("Canonical Host Name:" + inetAddress.getCanonicalHostName() + "\n");
print("Host Name:" + inetAddress.getHostName() + "\n");
print("Host Address:" + inetAddress.getHostAddress() + "\n");
}
InetAddress inetAddress = InetAddress.getLocalHost();
displayStuff("local host", inetAddress);
inetAddress = InetAddress.getByName("github.com");
displayStuff("github.com", inetAddress);

The following is some example output:

--------------------------
Which Host:local host
Canonical Host Name:b6fd975556d2
Host Name:b6fd975556d2
Host Address:172.19.0.2
--------------------------
Which Host:github.com
Canonical Host Name:140.82.121.3
Host Name:github.com
Host Address:140.82.121.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment