You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

git-ftp报错“fatal: Remote host not set”问题排查求助

Troubleshooting "fatal: Remote host not set." in git-ftp Pipeline

It’s frustrating when a pipeline that worked perfectly a month ago suddenly breaks with this error, especially when you’re sure your variables are configured correctly. Here are some targeted troubleshooting steps to fix this:

1. Verify Environment Variable Availability First

Even if you’re confident your variables are set, pipeline environments can sometimes have subtle issues with variable scoping or loading. Add a debug step to your script to confirm the variables are actually being passed correctly:

script:
  - apt-get update
  - apt-get -qq install git-ftp
  # Add these lines to debug
  - echo "FTP_HOST value: $FTP_HOST"
  - echo "FTP_USERNAME value: $FTP_USERNAME"
  - git ftp push --user $FTP_USERNAME --passwd $FTP_PASSWORD sftp://$FTP_HOST

If the FTP_HOST output is empty or incorrect, double-check:

  • Variable spelling (case sensitivity matters! Is it FTP_HOST or FTP_Host?)
  • Variable scope (is the variable configured for the develop branch specifically, or the entire project?)
  • Whether the variable was accidentally removed or modified in your pipeline settings.

2. Check for git-ftp Version Changes

You’re installing git-ftp via apt-get, which pulls the latest version available in the Debian repo. It’s possible a recent update to git-ftp (v1.3.1-1 in your log) introduced a breaking change in how it parses the sftp URL. Try pinning to an older version that worked before:

  1. Find the version of git-ftp that was working a month ago (you can check old pipeline logs if available).
  2. Modify your install command to specify that version:
apt-get -qq install git-ftp=1.2.0-1 # Replace with your working version number

If this fixes the issue, you’ve identified a version compatibility problem.

3. Ensure SFTP Dependencies Are Complete

The log shows your pipeline updated libcurl3 and curl to newer versions. Git-ftp relies on curl for SFTP transfers, and newer curl versions might require additional SSH/SFTP packages to function properly. Add these dependencies to your install step:

apt-get -qq install git-ftp openssh-client libcurl4-openssh-dev

This ensures all required libraries for SFTP connections are present.

4. Validate SFTP URL Format

Double-check that your SFTP URL is correctly formatted. Sometimes missing details like a remote path or port can cause git-ftp to fail to recognize the host:

  • If your SFTP server uses a non-default port, add it to the URL: sftp://$FTP_HOST:2222
  • If you need to target a specific directory on the server, append it: sftp://$FTP_HOST/path/to/your/folder

5. Reset git-ftp Remote Context (For Containerized Pipelines)

Since your pipeline runs in a fresh container every time, git-ftp doesn’t retain any cached remote settings. Ensure your push command is explicitly providing all necessary details. You can also try adding the --remote-root flag to explicitly define the remote directory, which sometimes helps git-ftp resolve the host correctly:

git ftp push --user $FTP_USERNAME --passwd $FTP_PASSWORD --remote-root /path/to/remote sftp://$FTP_HOST

内容的提问来源于stack exchange,提问作者ernesthm

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 07:25:25