cicd network_error ai_generated true

ERROR: Checkout failed: Could not resolve hostname github.com: Name or service not known

ID: cicd/jenkins-pipeline-checkout-failed

Also available as: JSON · Markdown · 中文
85%Fix Rate
88%Confidence
1Evidence
2024-01-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Jenkins 2.440 active
Git plugin 5.2.0 active
Alpine Linux 3.18 active

Root Cause

Jenkins pipeline failed to resolve the Git hostname due to DNS resolution failure, network misconfiguration, or proxy issues in the build environment.

generic

中文

Jenkins 流水线因 DNS 解析失败、网络配置错误或构建环境中的代理问题而无法解析 Git 主机名。

Official Documentation

https://www.jenkins.io/doc/book/pipeline/scm/

Workarounds

  1. 90% success Configure DNS servers explicitly in the Jenkins agent's /etc/resolv.conf or set the DNS in Docker if using containers: echo 'nameserver 8.8.8.8' >> /etc/resolv.conf
    Configure DNS servers explicitly in the Jenkins agent's /etc/resolv.conf or set the DNS in Docker if using containers: echo 'nameserver 8.8.8.8' >> /etc/resolv.conf
  2. 80% success If behind a proxy, set the proxy environment variables in the Jenkins node configuration: export http_proxy=http://proxy:8080; export https_proxy=http://proxy:8080
    If behind a proxy, set the proxy environment variables in the Jenkins node configuration: export http_proxy=http://proxy:8080; export https_proxy=http://proxy:8080

中文步骤

  1. Configure DNS servers explicitly in the Jenkins agent's /etc/resolv.conf or set the DNS in Docker if using containers: echo 'nameserver 8.8.8.8' >> /etc/resolv.conf
  2. If behind a proxy, set the proxy environment variables in the Jenkins node configuration: export http_proxy=http://proxy:8080; export https_proxy=http://proxy:8080

Dead Ends

Common approaches that don't work:

  1. 50% fail

    Restarting Jenkins only restarts the master; it doesn't fix DNS resolution in build agents unless they are restarted separately.

  2. 60% fail

    Pinging github.com from the master doesn't guarantee the agent can resolve it; agents may have different DNS settings.