winscp.ps1 1.1 KB

12345678910111213141516171819202122232425
  1. # Prerequisites
  2. # Environment Variables:
  3. # UPLOAD_USER - user to upload to sftp server
  4. # KEY is assumed to be path to a ssh key for UPLOAD_USER
  5. Param(
  6. [string]$DIR,
  7. [string]$KEY,
  8. [string]$FILE
  9. )
  10. Set-Variable -Name "UUSER" -Value "$env:UPLOAD_USER"
  11. Set-Variable -Name "UPLOAD" -Value "$($FILE | Resolve-Path)"
  12. if (Test-Path $KEY) {
  13. if ($env:APPVEYOR_PULL_REQUEST_NUMBER -Or $env:APPVEYOR_REPO_BRANCH -ne "master" ) {
  14. if ($env:APPVEYOR_PULL_REQUEST_NUMBER) {
  15. winscp.com /privatekey=$KEY /command "open sftp://$UUSER@dl.slic3r.org/$DIR/branches -hostkey=*" "rm *PR${env:APPVEYOR_PULL_REQUEST_NUMBER}*" "exit"
  16. }
  17. if ($env:APPVEYOR_REPO_BRANCH -ne "master" ) {
  18. winscp.com /privatekey=$KEY /command "open sftp://$UUSER@dl.slic3r.org/$DIR/branches -hostkey=*" "rm *${env:APPVEYOR_REPO_BRANCH}*" "exit"
  19. }
  20. winscp.com /privatekey=$KEY /command "open sftp://$UUSER@dl.slic3r.org/$DIR/branches -hostkey=*" "put $UPLOAD ./$FILE" "exit"
  21. } else {
  22. winscp.com /privatekey=$KEY /command "open sftp://$UUSER@dl.slic3r.org/$DIR -hostkey=*" "put $UPLOAD ./$FILE" "exit"
  23. }
  24. }