agent icon indicating copy to clipboard operation
agent copied to clipboard

Feature request: proxy support

Open chizmeeple opened this issue 11 years ago • 5 comments

Trying to use buildkite behind a (corporate) firewall/proxy is impossible.

In my case the initial attempt by the agent to register itself fails with connection errors.

A specific example of this is:

➔ docker run -e BUILDKITE_AGENT_TOKEN="my_token" buildkite/agent

_           _ _     _ _    _ _                                _
| |         (_) |   | | |  (_) |                              | |
| |__  _   _ _| | __| | | ___| |_ ___    __ _  __ _  ___ _ __ | |_
| '_ \| | | | | |/ _` | |/ / | __/ _ \  / _` |/ _` |/ _ \ '_ \| __|
| |_) | |_| | | | (_| |   <| | ||  __/ | (_| | (_| |  __/ | | | |_
|_.__/ \__,_|_|_|\__,_|_|\_\_|\__\___|  \__,_|\__, |\___|_| |_|\__|
                                                __/ |
http://buildkite.com/agent                    |___/

2015-06-24 15:02:57 NOTICE Starting buildkite-agent v1.0-beta.39.724 with PID: 1
2015-06-24 15:02:57 NOTICE The agent source code can be found here: https://github.com/buildkite/agent
2015-06-24 15:02:57 NOTICE For questions and support, email us at: [email protected]
2015-06-24 15:02:57 INFO   Registering agent with Buildkite...
2015-06-24 15:03:07 WARN   Post https://agent.buildkite.com/v3/register: net/http: request canceled while waiting for connection (Attempt 1/30 Retrying in 1s)
2015-06-24 15:03:17 WARN   Post https://agent.buildkite.com/v3/register: dial tcp: lookup agent.buildkite.com on 10.5.13.150:53: read udp 10.5.13.150:53: i/o timeout (Attempt 2/30 Retrying in 1s)
2015-06-24 15:03:28 WARN   Post https://agent.buildkite.com/v3/register: net/http: request canceled while waiting for connection (Attempt 3/30 Retrying in 1s)
2015-06-24 15:03:38 WARN   Post https://agent.buildkite.com/v3/register: dial tcp: lookup agent.buildkite.com on 10.5.13.150:53: read udp 10.5.13.150:53: i/o timeout (Attempt 4/30 Retrying in 1s)

With other applications I've been able to get round this by using:

# general workaround
export http_proxy=http://w.x.y.z:1234
export https_proxy=http://w.x.y.z:1234

More specifically for docker builds:

# /etc/sysconfig/docker
HTTP_PROXY=http://w.x.y.z:1234
HTTPS_PROXY=http://w.x.y.z:1234
http_proxy="${HTTP_PROXY}"
https_proxy="${HTTPS_PROXY}"
export HTTP_PROXY HTTPS_PROXY http_proxy https_proxy

I'm not sure what changes would be required for the agent to honour these environment variables, but it would be extremely useful to be able to route the agent through a proxy.

chizmeeple avatar Jun 24 '15 15:06 chizmeeple

Hrm, that's weird. It should work! https://github.com/buildkite/agent/blob/master/agent/api_client.go#L29 and http://golang.org/src/net/http/transport.go?s=4805:4862#L126

keithpitt avatar Jul 05 '15 16:07 keithpitt

Can you confirm that the HTTPS_PROXY ENV variable is getting to the agent? An easy way to do this, is to temporarily allow the agent access to the internet, and inside a build script, run env | HTTP

keithpitt avatar Jul 05 '15 16:07 keithpitt

I just double checked and I was able to use the agent through a proxy. Going to close this for now until I can get some more information. Feel free to re-open @chiselwright if you give it another go and can't get it working!

keithpitt avatar Jul 29 '15 22:07 keithpitt

Just thought id add this here as i ran into the same problem. The issue i have with http_proxy is when its on a systemd enabled system. Systemd service units do not pickup /etc/environment or other such places

So to fix this you need:

mkdir /etc/systemd/system/buildkite-agent.service.d
cat <<EOF > /etc/systemd/system/buildkite-agent.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://some-proxy-host:some-proxy-port"
EOF
systemctl daemon-reload
systemctl restart buildkite-agent

mrproper avatar Feb 16 '17 00:02 mrproper

@mrproper oh right, that's good to know. Sorry you ran into the same problem!

keithpitt avatar Feb 16 '17 23:02 keithpitt