Here is another website which has REST API support to get IP from hostname
Invoking this URL
**https://dns-api.org/A/<HOSTNAME>**
gives the output as below
[
{
"value" : "xxx.xxx.xxx.xxx",
"ttl" : 0,
"name" : "abcd.domain.com",
"type" : "A"
}
]
The updated method to convert host name to Ip would be as below
private String convertHostnameToIPAddress(hostname) {
def params = [
uri: "https://dns-api.org/A/" + hostname
]
def retVal = null
try {
retVal = httpGet(params) { response ->
doDebug("convertHostnameToIPAddress -> Request was successful, data = $response.data, status=$response.status")
for(result in response.data) {
if (result.name == hostname) {
return result.value
}
}
}
}
catch (Exception e) {
log.warn "Unable to convert hostname to IP Address, Error: $e"
}
return retVal
}
Hope this helps