Launching Robocopy from appveyor.yml

jay's Avatar

jay

Aug 26, 2015 @ 06:00 PM

I'm trying to add robocopy to my yml file to help create artifacts. I'm struggling with the syntax, I think there are perhaps special characters or parsing rules for ps: or cmd: that I don't understand.

My goal is to invoke robocopy like this:

cmd: (robocopy XXX YYY) ^& IF %ERRORLEVEL% LEQ 4 exit /B 0

per this article on straightening out robocopy's non-standard return codes:

http://superuser.com/questions/280425/getting-robocopy-to-return-a-proper-exit-code

My specific yml lines are:

before_build:
  - cmd: (robocopy /mir . source /xd source external .git packages /NFL /NDL /NJH /nc /ns /np) ^& IF %ERRORLEVEL% LEQ 4 exit /B 0

what I get back in my build logs is:

'3' is not recognized as an internal or external command,
operable program or batch file.
Command exited with code 1

  1. Support Staff 1 Posted by Feodor Fitsner on Aug 26, 2015 @ 06:54 PM

    Feodor Fitsner's Avatar

    When any 'cmd' line runs it's being wrapped into another .cmd with call <cmd-line>. Maybe there is something related to this.

    Try running it as -cmd: cmd /c (robocopy ... or put the command into a separate copy.cmd?

  2. 2 Posted by jay on Aug 26, 2015 @ 07:35 PM

    jay's Avatar

    Unfortunately that didn't do it. This resulted in the line being ignored and no copy performed.

    Here is my yml:

    before_build:
      - cmd: cmd /c (robocopy /mir . source /xd source external .git packages /NFL /NDL /NJH /nc /ns /np) ^& IF %ERRORLEVEL% LEQ 4 exit /B 0

  3. 3 Posted by jay on Aug 26, 2015 @ 07:38 PM

    jay's Avatar

    Asked another way, is there some way to invoke a program without checking its return code? The core of the issue is that appveyor (and most batch environments) check the RC for 0 and fail if not but robocopy was written with RCs 1-8 meaning success.

  4. Support Staff 4 Posted by Feodor Fitsner on Aug 26, 2015 @ 07:39 PM

    Feodor Fitsner's Avatar

    Ah, that's explains the thing. Try running it as PowerShell with - ps: prefix.

  5. 5 Posted by jay on Oct 16, 2015 @ 02:45 AM

    jay's Avatar

    FYI, that didn't work and I've never solved this. I wanted to create an artifact to preserve matching sources at build time, I'm still stumped :-(

  6. Support Staff 6 Posted by Feodor Fitsner on Oct 16, 2015 @ 02:54 AM

    Feodor Fitsner's Avatar

    You can just put that command into .cmd file and commit to the repo.

  7. jay closed this discussion on Dec 31, 2015 @ 06:01 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac