Going from top to bottom, first task is version, it just gets the package version from package.json file and outputs it to the console. I use this in Jenkins.
Next comes clean. It just removes build generated files, for next build to start from a clean slate.
Next comes lint. I like to lint my code and know about issues with my code sooner than later. Based on Jenkins environment variable I decide which report format to use. During development I like to use stylish and for Jenkins, checkstyle to generate checkstyle xml and report it nicely in Jenkins using checkstyle plugin.
Next comes test. It does both unit testing and code coverage. This will generate test and code coverage reports, both on console using text and xml files to be used by jUnit and Cobertura plugins to generate nice graphs and reports in Jenkins.
Next comes server:start. Which simply start my node server in development.
Final three are watch, build, default. build is combo task that runs clean, lint and test in that order. watch watches my files for changes and it triggers build and restarts the dev server automatically every time I make a change to my code. default task (which is triggered when you run gulp without passing any task) builds the projects, starts the server and watches for file changes. This way I just type gulp and I’m ready to work on my project. Notice that server:start and watch tasks are executed in parallel because both are blocking.
This is the build cycle for this type of projects. I do like to use docker to run my node apps so at the end of build I like to generate a docker image and put it on docker registry (this is where version comes handy.) My other post explains how to run node apps in docker:
Make sure to also check my other gulp files out: