I'm working on the something right now as our security team doesn't want to have to manage cygwin on all of our windows vms. My current attempt is to use powershell on the windows vm to download a file from an http server running on the same box as rundeck (I think it may be possible to use the tomcat instance of rundeck when running a war file to server the files as well). I am planning to use a script execution for my file copy agent. The script I'm using will flow something like this:
1). Copy ${file-copy.file} to <websrv-root>/htdocs/tmp/${file-copy.filename}
2). execute rd-tool to call "winRM_File_copy" job in rundeck and provide an override filter, and winRMPassword option.
3). rm <websrv-root>/htdocs/tmp/${file-copy.filename}
I've hit a snag right off the bat that the winrm executor seems to be trying to escape the single-quotes ( ' ) twice as they end-up being sent over as ' " ' " ' (spaces added for readability, written out that is single-quote, double-quote, single-quote, double-quote, single-quote). If you run the command with powershell as the interpreter you will see ' ' ' as powershell throws out the double-quotes. I was able to run the command with double-quotes by escaping with a back-slash ( \ ) so the command is `powershell (new-object System.Net.WebClient).DownloadFile(\"
http://rundeck:8080/tmp/${option.Temp_File}\",\"${option.Destination}\")` but, powershell does not consider the double-quote valid and complains it cannot find the closing ")". I was unable to escape a single-quote.
I'm trying to find work-around for the quoting issue but, I have opened
https://github.com/rundeck-plugins/rundeck-winrm-plugin/issues/22. I did notice that if I don't use any variables but, just have a static command I don't have this issue.