下面按常见场景给你说明:Jenkins 怎么通过 Debian 上的代理(HTTP/HTTPS 代理) 访问外网(比如装插件、拉代码)。
如果 Debian 本身已经能走代理,只让 Jenkins 走代理:
编辑 Jenkins 的 systemd 配置:
sudo systemctl edit jenkins
加入:
[Service]
Environment="JAVA_OPTS=-Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=7890 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=7890"
(把 IP 和端口换成你的代理)
保存后:
sudo systemctl daemon-reload
sudo systemctl restart jenkins
系统管理 → 插件 → 高级(Advanced)
勾选: ✅ 使用代理
填写:
localhost,127.0.0.1)✅ 这是 插件下载 最稳定的方式。
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890
sudo nano /etc/environment
加入:
http_proxy="http://127.0.0.1:7890"
https_proxy="http://127.0.0.1:7890"
Jenkins 以 systemd 启动时,不会自动读 /etc/environment,仍需方法一或二。
如果是 Agent 连 Master 或拉 Git:
export http_proxy=...
export https_proxy=...
或在 jenkins-agent 启动脚本加:
-Dhttp.proxyHost=...
-Dhttps.proxyHost=...
✅ Git 拉不下来
git config --global http.proxy http://127.0.0.1:7890
✅ Docker 构建走代理
mkdir -p /etc/systemd/system/docker.service.d
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:7890"
Environment="HTTPS_PROXY=http://127.0.0.1:7890"
如果你能说清楚:
我可以直接给你可复制的配置。