Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to integrate cmake in gitlab repository for Continuous Integration(CI)

I was able to run the C++ Program and build & test it using GitLab CI unit with the help of Docker Image of gcc. But now I want to compile the program in docker using cmake instead of g++. How to change the '.gitlab-ci.yml' file to support cmake.

Current File : .gitlab-ci.yml

image: gcc
before_script:
   - apt-get install --yes cmake libmatio-dev libblas-dev libsqlite3-dev libcurl4-openssl-dev
   - apt-get install --yes libarchive-dev liblzma-dev

build:
  script:
    - ./runner.sh
    - ./bin/hello

./runner.sh

cmake -H. -Bbuild
cmake --build build -- -j3
like image 584
Thomas Easo Avatar asked Nov 15 '17 16:11

Thomas Easo


People also ask

Is GitLab continuous integration?

GitLab Continuous Integration and Delivery automates all the steps required to build, test and deploy your code to your production environment. Continuous integration automates the builds, provides feedback via code review, and automates code quality and security tests.

Can GitLab be used for CI CD?

Build, test, deploy, and monitor your code from a single application. deployment speed. GitLab has CI/CD built right in, no plugins required.


1 Answers

I think you need to add apt-get update in order to get cmake to install. See this

image: gcc
before_script:
 - apt-get update --yes
 - apt-get install --yes cmake

build:
  script:
    - ./runner.sh
    - ./bin/hello

In general, you can figure stuff out by jumping into the docker image to debug (in your case the image is the debian-based gcc:latest):

sudo docker run -it --rm gcc

If you had run your original apt-get install command inside the gcc container, you would have seen following error message that you could have then googled to figure out that apt-get update was needed

sudo docker run -it --rm gcc apt-get install --yes cmake
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package cmake is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'cmake' has no installation candidate

As this blog post mentions, you can do a test run locally by downloading the gitlab-runner executable:

gitlab-runner exec docker build

Running the gitlab-runner locally will have gitlab clone your repo and run through all the steps in the .gitlab-ci.yml and you can see the output and debug locally rather quickly.

like image 199
nktiwari Avatar answered Nov 14 '22 12:11

nktiwari