I believe I've found an answer to my own question.
Steps:
- Install the Conditional Build Step plugin.
- Install the Fail The Build plugin.
- Add a batch script that returns error code 1 if the tests-to-run file size is 0, or error code 0 otherwise.
- Add a single conditional build step:
- Execute Windows Batch Commands == the path to the batch file.
- Set the build result == Unstable (or whatever).
My batch file code:
@echo off
REM Retrieve the build name.
set arg1=%1
REM Set the file name.
set file="C:\Path\To\TestsToRunFile\%arg1%.txt"
REM Get the file size.
FOR /F "usebackq" %%A IN ('%file%') DO set size=%%~zA
REM Exit codes based on the file size.
IF %size% EQU 0 (
exit /b 0
) ELSE (
exit /b 1
)