Get Started with Continuous Integration (CI)

Visual Studio developers have a number of options for how you can integrate Cordova apps with your favorite continuous integration (CI) server thanks to the fact that projects created in Visual Studio are standard Apache Cordova Command Line Interface (CLI) projects. Any build tools that work with Cordova application projects should work just fine with projects created with Visual Studio Tools for Apache Cordova (TACO).

Visual Studio Team Services

Development organizations using Visual Studio Team Services (VSTS) can add Cordova tasks to the build process using the Cordova Build cross-platform agent for VSTS. This new agent enables you to use VSTS build projects targeting Android, iOS, or Windows applications created using Tools for Apache Cordova or any Cordova compliant CLI like Ionic and Adobe PhoneGap.

Apache Cordova logo Cordova Build
Visual Studio Client Tools
Streamline CI setup for your Apache Cordova, PhoneGap, Ionic, or Cordova CLI compatible app using a set of useful pre-defined build steps.
Install now!

See the quick start on the extension page along with the detailed Build Apache Cordova apps with Visual Studio Team Services tutorial.

Gulp

If you would prefer not to use the extension or are not using VSTS, you can get your project running in nearly any CI system quickly using the taco-team-build node module and Gulp. Note that the method described here can be used with Jenkins, as an alternative for VSTS, and others; see Tutorials on Specific CI Systems for details.

To use Gulp with your Cordova projects, follow these steps:

  1. Install dependencies: Install Visual Studio 2017 and the Tools for Apache Cordova on your build server or simply install the prerequisites for the platforms you are targeting separately:

    • Visual Studio itself is only required if you are building for Windows or Windows Phone.
    • Install Node.js and you'll also need to install the Git command line tools on Windows.

      Note

      The default option for the Git installation does not add Git to the system PATH environment variable. To fix this, select the option to run the tools from the command prompt, this will add the Git installation folder to the system PATH.

    • Android requires the Java SDK and the Android SDK with the correct API level installed. Add environment variables for ANDROID_HOME pointing to your Android SDK installation folder, and JAVA_HOME to your Java install.
    • iOS requires Xcode (from the Mac app store) and Node.js
    • See the General CI tutorial or Install Dependencies Manually in MSDN for some information on what to install for a given platform.
  2. Add or Update the package.json in your Cordova project: Add the following development dependencies to your Cordova project's package.json file.

    Note

    You can use this version if you do not yet have a package.json file in the root of your project.

    {
      "devDependencies": {
        "gulp": "^3.9.1",
        "gulp-typescript": "^2.11.0",
        "taco-team-build": "^0.2.2"
      }
    }
    
  3. Add a gulpfile.js to your project: Add this Gulp file to the root of your project.

    gulpfile.js in project

  4. Try it locally: Test out your build by opening a command prompt (or terminal window on Macintosh), navigating to the Cordova project's root folder (the folder with the project's www folder), and executing the following commands:

    npm install
    node_modules\.bin\gulp
    

    ...or on a Mac...

    npm install
    ./node_modules/.bin/gulp
    

    Gulp will build Android and Windows versions of your project when run from Windows and iOS when run from OSX. You can change this behavior by updating the following lines in gulpfile.js.

    var winPlatforms = ["android", "windows"],
        osxPlatforms = ["ios"],
        ...
    
  5. Add to source control: Assuming all goes well, add your project into the appropriate source code repository.

  6. Configure CI: Configure your Team/CI server to fetch your Cordova project and execute the same commands mentioned above from the root of your Cordova project. You can find detailed instructions for certain CI systems below.

  7. Windows & OSX Build Agents: Finally, configure a build agent / subordinate on both Windows and OSX so you can build for any platform. See the tutorials below for some specifics on how to configure your CI system.

That's it!

Tutorials on specific CI systems

For additional information on how to configure specific build systems, see the following tutorials:

The following articles provide additional details and troubleshooting information: