Here is the solution. The issue was with the license files in the $sdk/licenses directory. To resolve:
- delete the $sdk/licenses directory on CI machine
- recreate the $sdk/licenses directory on CI machine with the following files (which you should copy from your local machine):
android-sdk-license, android-sdk-preview-license
Now, CMake installs and builds fine.