I’m using Jenkins on a Windows server. I set up a simple pipeline that should simply clone a repo with python files, eventually run pytest on the test files and fail the pipeline if the tests didn’t finish successfully. But this is not working.
For a particular reason the python code raises an NotADirectoryError: [WinError 267] The directory name is invalid: 'C:\\Windows\\TEMP\\tmpeola6z2l\\Test.log' the reason might be lack of access rights. However Jenkins just goes on, where I would expect it would automatically fail, what’s wrong here?
It is certainly correct to use CALL in front of conda.bat, and it should be OK with python as well.
The CALL documentation refers to the behaviour that, if file1.bat runs file2.bat without CALL, then subsequent commands of file1.bat will not be executed at all. This behaviour is somewhat like exec in POSIX sh, except it is the default. COMMAND.COM in MS-DOS works this way (perhaps to minimise memory use) and CMD.EXE in Windows remains compatible with that. If there is a chance that the python commands might find a python.bat file along the PATH, then it is safest to use CALL.
I’m not sure how CALL works with || though.
POSIX sh has “set -e” to make the shell exit if a command returns with a nonzero exit code. CMD.EXE does not have a similar feature.
One thing you could try is replace the || exit with a separate ERRORLEVEL check
call python -m pytest %WORKSPACE%
IF ERRORLEVEL 1 (
ECHO pytest exit code is not zero
in order to verify whether the exit code is lost between pytest and CMD, or between CMD and Jenkins.
If now I would replace %ERRORCODE% with something fixed != 0, it’ll enter the if-branch, exit the batch with error 1 and Jenkins fails. However %ERRORCODE% is always 0, the python status never gets picked up by it
I think I found the solution, it is with calling bat( instead of bat """, currently verifying