How to make job failed with xcopy

Hi,

we execute Windows batch command and we use xcopy to copy web.config file"

set webconfig=C:\Program Files (x86)\Jenkins\customWorkspace\Staging\Configs\Sky24SPA\web.config
@REM Get proper config
xcopy “%webconfig%” “%backendBuildDir%” /y

but when the file doesn’t exist we want build to be failed. Normallny withoud /c parameter xcopy throws error code , but Jenkins doesn’t use this error and goes furher with the build.
After file doesn’t exist we want build to end.

Could you help?

You have any other commands inside the batch file after the xcopy command?
If yes you will need to check the errorlevel inside an if statement and properly exit the batch script if it is not the right value.
Windows batch script are never stopped once a command returns a non zero exit code contrary to bash script where you can enable such a behavior (Jenkins enables it by default, but it can be overridden inside a script)

Check out the information here, it provides a good overview and information. How do I make a batch file terminate upon encountering an error? - Stack Overflow