Do you know how to check if you have internet access on your CI server?
You can simply make a get request to any page, for example https://www.google.com but this will not be an effective solution, since you do not need the HTML code that will come in response.
The most correct way is to make a get request to https://www.google.com/generate_204 since the response will only contain the header.
If you work with Ruby or Rails, I recommend using this wonderful gem online
It does exactly what is described above.