How to compile Arduino ESP8266/32 on CI/CD (CLI shell cmd) platform?
Easiest answer: Use PlatformIO. (Yes this answer is technically an advertisement, but it is the correct solution here.). 

Why not the others? 


makeEspArduino is dependent on GNU make, hard to make modification to, hard to get support for when something goes wrong
Visual Micro Arduino is Visual Studio extension, thus native to Windows


Why PlatformIO?

On the other hand, PIO is just a framework written in python2, runs on Windows, Mac &amp; Linux alike and supports tons of boards and frameworks. Not only is it OS-agnostic but it also IDE agnostic. It exports project files for Eclipse, Visual Studio Code, CLion, Visual Studio, Sublime, Atom and other IDEs. The Arduino IDE will always be only a (bad) syntax highlighter.

Support boards (479 of them) range from Arduino Unos to ESP8266/ESP32 over to STM32 and nRF boards. It's also possible to compile one firmware for different environments (board), so with a well-written firmware, PIO can generate firmwares for multiple boards and frameworks alike. Frameworks include Arduino cores, ESP-IDF, STM32HAL and more.

To create a new project, you'd do

user@somefolder/$ pio init --board=nodemcuv2 --ide=vscode


To compile from CLI, you just have to execute the run target:

user@somefolder/$ pio run 


To upload you'd just

user@somefolder/$ pio run -t upload 


With optional --upload-port=/dev/ttyUSB0 or alike. Updating wirelessly over ArduinoOTA is also supported.

Video: https://www.youtube.com/watch?v=EIkGTwLOD7o

Documentation: http://docs.platformio.org/en/latest/