New scripts not found when building in batch mode

We setup an automatic build machine which builds our unity project after each commit. Build runs unity editor with -batchmode flag. Editor fails with “script not found” every time a new script is added to the project, though script is present in the Assets folder. When build is executed again, without any project changes, compilation passes. Seems problem appears only in the batch mode.

How do we force unity to detect new scripts in the project?

The problem is that unity refreshes asset database only after running -executeMethod in batch mode.
The workaround is to run unity twice.

Unity -quit -batchmode
Unity -quit -batchmode -executeMethod "EditorScript.Test"

Unity should refresh before the script execution, I’ve submitted a bug report

I think you need: AssetDatabase.Refresh() in your build script.