When you are working on production you usually doesn’t have direct outgoing connection enabled or it could be really limited.
Here you can find a collection of configuration for different software for working via proxy. Let as assume that in all next examples we are talking about http proxy working on host
githib.com behind proxy
Github could be accessed via various protocols
You can talk to github.com at 443 port as well see ssh over https port
General proxy solution could be build (and you can use it of other cases) with corkscrew utility.
corkscrew could be used for tunneling ssh connections in pretty handy way
curl & wget
Just export system variables
gradle & gradlew
It follows standard java application proxy configuration, just to enable it isolated, it is better to use gradle specific env variable