Main Content

Develop and Integrate Software with Continuous Integration

Continuous integration (CI) is the practice of integrating code changes into a shared repository on a frequent basis. It improves team throughput and software quality by automating and standardizing activities such as building code, testing, and packaging. For example, each time a developer pushes new committed changes to the remote repository, the continuous integration platform can automatically run a suite of tests to ensure that the changes do not cause any conflicts in the target branch of the remote repository.

The benefits of continuous integration include:

  • Finding problems in software and fixing them soon after they are introduced.

  • Adding more features while reducing the resources required for debugging code.

  • Minimizing integration and deployment overheads by performing integration on a continuous basis.

  • Clearly communicating the state of software and the changes that have been made to it.

Continuous Integration Workflow

A typical software development workflow using continuous integration involves several steps:

  1. Cloning the remote repository and creating a feature branch

  2. Editing files and committing the changes to the local repository

  3. Pushing the committed changes to the remote repository (which triggers an automated pipeline of tasks such as compiling MEX files, running tests, and packaging toolboxes on the CI platform)

  4. Analyzing the reports generated by the CI platform and fixing the errors within the pipeline

  5. Merging the remote feature branch into the main branch through a pull request (which triggers another automated pipeline of tasks on the CI platform)

  6. Analyzing the reports generated by the CI platform and resolving the merge failures

This figure shows an example of the development cycle using the Jenkins® CI server and open-source source code management tools such as Git™ and GitHub®. For information on how to interface MATLAB® with Jenkins, see Run MATLAB Tests on Jenkins Server.

An example of the development cycle using continuous integration

Phase 1: Develop and Qualify Feature in Local Repository

Develop a feature and commit your changes to the local repository:

  1. Clone the GitHub repository and create a new feature branch.

  2. Make changes to the existing files or add new files as appropriate.

  3. Run MATLAB and Simulink® tests to qualify the changes and commit them to the local repository.

Phase 2: Run Automated Pipeline on Continuous Integration Platform

Run an automated pipeline of tasks (including testing) when you push your changes to the remote repository or when you make a pull request:

  1. Trigger an automated pipeline of tasks on Jenkins by pushing the committed changes to GitHub or by making a pull request to merge the remote feature branch into the main branch.

  2. Jenkins runs the automated pipeline, including MATLAB and Simulink tests, and generates artifacts as specified in the project configuration.

Phase 3: Investigate and Resolve Failures

If you do not succeed in pushing your changes or making a pull request, follow these steps:

  1. Inspect the automated pipeline results and the generated artifacts. Make appropriate changes to your code.

  2. Trigger a new pipeline on Jenkins by pushing your changes to GitHub or by making a pull request.

Integration engineers can use Jenkins artifacts to decide when to merge the feature branch into the main branch.

Continuous Integration with MathWorks Products

You can perform continuous integration with MATLAB on various continuous integration platforms. You can run and test your MATLAB code and Simulink models, generate artifacts, and publish your results to the platforms. For more information, see Continuous Integration with MATLAB on CI Platforms.

In addition to MATLAB, different toolboxes support continuous integration workflows. This table lists common continuous integration use cases for models and code.

ToolboxUse CaseMore Information
Simulink

  • Build and test models and projects

  • Cache files for simulation and code generation

About Source Control with Projects (Simulink)

Using a Project with Git (Simulink)

Share Simulink Cache Files for Faster Simulation (Simulink)

Attach Model Comparison Report to GitHub Pull Requests (Simulink)

Simulink Test™

Run test files on CI platforms and collect CI-compatible coverage using Simulink Coverage™

Continuous Integration (Simulink Test)

Simulink Check™

Deploy automated processes to your team to help them identify, automate, and complete development and verification activities

Continuous Integration (Simulink Check)

Requirements Toolbox™Summarize requirements verification results for tests run on CI platforms

Include Results from External Sources in Verification Status (Requirements Toolbox)

Polyspace® Bug Finder™ Server™, Polyspace Code Prover™ Server

  • Run a Polyspace analysis on C/C++ code as part of continuous integration, for instance with Jenkins

  • Upload the analysis results (bugs, run-time errors, or coding standard violations) for review in the Polyspace Access web interface

  • Send e-mail notifications with Polyspace Bug Finder or Polyspace Code Prover results

Set Up Bug Finder Analysis on Servers During Continuous Integration (Polyspace Bug Finder)

Set Up Code Prover Analysis on Servers During Continuous Integration (Polyspace Code Prover)

See Also

Functions

Namespaces

Related Topics

External Websites