Jenkins Publish over SSH插件无法复制构建归档求助
Hey there, sorry to hear you’ve spent hours troubleshooting this Jenkins SSH file transfer issue—let’s walk through the most common fixes to get your archive copied over successfully.
1. Double-Check Your Archive & Source File Paths
First, confirm the build task that generates your archive is actually producing the file where you expect it:
- Go to your build job’s workspace (you can find the path in the job’s Workspace tab) and verify the archive file exists.
- In the Publish over SSH configuration of your deploy job, make sure the
Source filespath matches exactly where the archive lives relative to the Jenkins workspace. For example, if your archive is attarget/my-app.zip, don’t write justmy-app.zip—usetarget/my-app.zip(or**/my-app.zipif you want to match recursively). - Also, ensure you haven’t accidentally checked the
Excludebox next to the source path, which would skip copying the file entirely.
2. Validate SSH Server Connection & Remote Directory
If the path checks out, the issue is likely with the remote server setup:
- Head to Manage Jenkins > Configure System > Publish over SSH, find your remote server entry, and click
Test Configuration. If this fails, fix the connection first—common issues include incorrect SSH key, wrong port (default is 22), or the remote server’s firewall blocking Jenkins’ IP. - Verify the
Remote directoryis correct: this path is relative to the SSH user’s home directory. For example, if your SSH user isdeploywith home/home/deploy, settingRemote directorytoapp-buildswill target/home/deploy/app-builds. Make sure this directory exists on the remote server, and the SSH user has write permissions:mkdir -p /home/deploy/app-builds && chown deploy:deploy /home/deploy/app-builds - If you’ve added an
Exec commandafter file transfer, temporarily remove it—sometimes a failing post-transfer command can mask that the file copy never happened.
3. Enable Verbose Logging to See Exact Errors
The default Jenkins log for Publish over SSH is way too vague. Let’s turn on debug logging to get concrete details:
- Go to Manage Jenkins > System Log >
Add new log recorder - Name it something like
SSH Publish Debug, then add the loggerjenkins.plugins.publish_over_sshand set its level toALL - Rerun your deploy job—you’ll now see detailed logs about what the plugin is doing: whether it’s finding the source file, connecting to the remote server, encountering permission errors, etc. This will almost certainly point you to the root cause.
4. Check Jenkins Agent Permissions (If Using Agents)
If your build runs on a Jenkins agent (not the master node):
- Confirm the agent’s workspace has the archive file, and the agent’s OS user has read access to it.
- Ensure the agent can reach the remote SSH server (test SSH connectivity from the agent machine manually to rule out network issues).
- Double-check that the Publish over SSH plugin is configured to run on the correct node (some jobs are tied to specific agents, and the plugin needs access to the archive on that node).
5. Try Switching Transfer Modes
Publish over SSH supports two transfer modes: SCP and SFTP. Sometimes server configurations block one of these protocols. Head to your remote server’s configuration in the plugin settings, switch the Transfer mode option, and re-run the job to see if it works.
内容的提问来源于stack exchange,提问作者Radu

