How do I stop robocopy from exiting the assembly?

I am using Gitlab 8.15.4 and the latest runner for this build. Due to our firewall, I cannot run npm install, so I copy node-modules from elsewhere to the build folder. The runner is on a Windows 7 machine.

My first try: (.gitlab-ci.yml)

before_script:
- robocopy S:\Storage\GitLab-Runner\Assets\node_modules .\node_modules /s
build:
  stage: build
  script:
    - echo starting
    - gulp
    - echo done
  artifacts:
    paths:
    - deploy.zip   

      

Failed to build with error:

ERROR: Job failed: exit status 1

My second (nth) attempt is putting robocopy into a script file and executing it from there:

(. Gitlab-ci.yml)

before_script:
- S:\Storage\GitLab-Runner\Scripts\CopyAssets.bat
build:
  stage: build
  script:
    - echo starting
    - gulp
    - echo done
  artifacts:
    paths:
    - deploy.zip   

      

(CopyAssets.bat)

robocopy S:\Storage\GitLab-Runner\Assets\node_modules .\node_modules /s
set/A errlev="%ERRORLEVEL% & 24"
exit/B %errlev%     

      

Passes but does not take any other steps.

How can I prevent RoboCopy from exiting the assembly when it finishes?

+3


source to share


1 answer


You and many other people have faced this issue using robocopy in a CI deployment. Since I found this question to be unanswered for some time and the rest of the answers are incompatible with continuing the script after robocopy, I want to share this solution here.

If you want robocopy to ignore all return codes in 8 (> = 8 means copy error), then you need a condition that follows the command directly and changes the error level.



(robocopy src dst) ^& IF %ERRORLEVEL% LSS 8 SET ERRORLEVEL = 0

      

+4


source







All Articles