When building your app using BrowserStack your build fails with an UnknownHostException error:
java.net.UnknownHostException: prd-20-04-usc1b-220309133144-sny9nhmtmjrqxdjxrupapg: prd-20-04-usc1b-2203091222144-snyasdnhmtmjrqxdjxrupapg: Name or service not known
To fix this issue, you should change the default DNS server to Google’s DNS server,
126.96.36.199. This way, Java can use it to resolve the host every time.
To change the DNS server to 188.8.131.52, include the following in a Script Step:
networksetup -setdnsservers Ethernet 184.108.40.206
You should clear your DNS cache to ensure your old DNS address is no longer in use. To do so, add:
networksetup -getdnsservers Ethernet
Finally, to verify that the change was successful, you can print the current DNS server with the following script:
Add the Script Step to your Workflow before any Steps that use BrowserStack.
Combining the information from above, the Script Step should look like this:
steps: - script@1: inputs: - content: |- #!/usr/bin/env bash # fail if any commands fails set -e # make pipelines' return status equal the last command to exit with a non-zero status, or zero if all commands exit successfully set -o pipefail # debug log set -x networksetup -setdnsservers Ethernet 220.127.116.11 networksetup -getdnsservers Ethernet scutil --dns