Compile and test a C application

Using Codefresh pipelines

Codefresh can work with any C/C++ application very easily as both gcc and g++ are already offered in Dockerhub. There is also another example available with C++ and cmake.

The example C project

You can see the example project at The repository contains a C starter project with a Makefile and several targets:

  • make compiles the code.
  • make test runs unit tests
  • make clean removes artifacts and binaries.

There are also extra targets for tags and etags.

Create a CI pipeline for C applications

Creating a CI/CD pipeline for C is very easy, because Codefresh can run any gcc image that you wish. Gcc docker images already contain the make utility.

Compiling a C application in a pipeline

Compiling a C application in a pipeline

Here is the full pipeline that compiles the application after checking out the code.


version: '1.0'
  - checkout
  - build
    title: Cloning main repository...
    stage: checkout
    type: git-clone
    repo: 'codefresh-contrib/c-sample-app'
    revision: master
    git: github
    title: Compile
    stage: build
    image: gcc
      - make
    title: Test
    stage: build
    image: gcc
      - make test   

This pipeline clones the source code, compiles the code and runs unit tests. In all cases we use the public Docker image of Gcc that also contains make.

C++ example
Codefresh YAML for pipeline definitions
Steps in pipelines
Creating pipelines
How Codefresh pipelines work