appleboy / drone-scp

Copy files and artifacts via SSH using a binary, docker or Drone CI.
MIT License
142 stars 30 forks source link

Linux scp to windwos server got drone-scp error: Process exited with status 4294967295 #185

Open bestK opened 1 year ago

bestK commented 1 year ago

Drone log

latest: Pulling from appleboy/drone-scp
Digest: sha256:eb6845ad3b2218e45fc21fede10a8aba1a17d2c0657506fcff572ccc505f1cdb
Status: Image is up to date for appleboy/drone-scp:latest
drone-scp version: v1.6.11
tar all files into /tmp/dxaMUwUbwS.tar.gz
tar: removing leading '/' from member names
remote server os type is unix // ❓ why is unix
scp file to server.
Remove target folder: /D/xxx/apache-tomcat8788/webapps/
drone-scp error:  Process exited with status 4294967295
drone-scp rollback: remove all target tmp file
remove file dxaMUwUbwS.tar.gz
2023/09/08 08:24:49 Process exited with status 4294967295
Remove target folder: /D/xxx/apache-tomcat8788/webapps/
drone-scp error:  Process exited with status 4294967295
drone-scp rollback: remove all target tmp file
remove file dxaMUwUbwS.tar.gz
2023/09/08 08:24:49 Process exited with status 4294967295

This below is not work

When copying files from a Linux runner to a Windows server, you should:

Download git for Windows
Change the default OpenSSH shell to git bach with the following powershell command.
Set tar_dereference and rm variable to true in the YAML file
Avoid putting the port value through a variable
Convert the target path to a Unix path: /c/path/to/target/
Change the default OpenSSH shell to git bach with the following powershell command.

New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "$env:Programfiles\Git\bin\bash.exe" -PropertyType String -Force
Convert the target path to a Unix path: /c/path/to/target/

  - name: Copy to Windows
      uses: appleboy/scp-action@v0.1.4
      with:
        host: ${{ secrets.HOST }}
        username: ${{ secrets.USERNAME }}
        key: ${{ secrets.SSH_PRIVATE_KEY }}
        port: 22
        source: 'your_source_path'
-       target: 'C:\path\to\target'
+       target: '/c/path/to/target/'
+       tar_dereference: true
+       rm: true
[root@ci build_target]# scp xxx.war admin@192.168.1.166:/D/
scp: Failed to open file /D/.
lost connection
[root@ci build_target]# scp xxx.war admin@192.168.1.166:/
xxx.war                                    100%  266MB  31.1MB/s   00:08

drone-scp always Process exited with status 4294967295