Writing a .gitlab-ci-yml file

Hi,
I am trying to figure out how to write a gitlab-ci.yml configuration file. I found this post How does the GitLab CI yml file work? in this forum, but it doesn’t really answer the questions I have.

I would like to build and run tests for a C++ project.
Is there any example for how a configuration file could look like?

Does it matter where I put the configuration file?

2 Likes

I think the yml file goes in the root of the project, at least thats where I’ve put it and it finds it successfully. Unfortunately that’s where my success ends.

I completely agree. There is general documentation that says this is the syntax, and so forth, but there are HUGE gaps between that and getting a system up and running. For example:

  1. is the code automatically pulled from the repo for you. If so where?
  2. are there environment variables that are globally set, for example, with the project name, url, git url, etc
  3. When is the environment (disk) wiped between “stages” or does my build stick around?
    There are just so many questions I don’t even know where to start. It’s worse that all the examples seem to be in ruby and so I don’t know if its just ruby because that’s what they use, or if all scripts must be in ruby. Some alternatives would be nice.

I also saw in a doc that there is a syntax checker (lint) for the .gitlab-ci.yml file but it says it’s available with the short url ‘/lint’. Say what? Where do I use this “short url” that you speak of?

So many questions, so few answers, and so little time with an active project to search for my own answers, crawl through code, etc…

Anyone used CI for anything other than Ruby? I’m using javascript on this project, but having another example, such as C++, would allow me to see how to tailor it to my (and the OP, I assume)needs.

Thanks,
Dave

Hello,
So I have figured out the yml file myself and would like to share my findings.
This is kind of what my yml file looks like.

types:

  • analyze
  • build
  • test

analyze-server:
type: analyze
allow_failure: true
script:

  • cd Debug
  • make clean
    tags:
  • openSUSE13.2

build-server-debug:
type: build
script:

  • cd Debug
  • make clean
    tags:
  • openSUSE13.2

build-server-release:
type: build
allow_failure: true
script:

  • cd Release
  • make clean
    tags:
  • SLES11SP3

To answer your questions dpankros:

  1. The CI is automatically pulling the code using git to the runner. The files are placed in this folder. “gitlab-runner@opensuse13-2-runner:~/builds/”.
  2. I didn’t have to specify any env variables. Make sure you enable a runner for your project.
  3. It is only the last build of every project, regardless of which branch, that is found in the folder above.

I am only using gitlab and CI for C++, but there shouldn’t be any difference if you are programming in another language. The runner is quite dumb and doesn’t anything about the content.

Mange

1 Like

Thank you for your information,

Now I have some questions about that…

  1. You have said that it´s only the last build of every project which is found in the folder so, how do you know if your last build is successful or failure?
  2. I´m trying to build my own c++ project but all my commits are success and without builds. What way did you write on your script for building the project?

Thank you,

Andrés

  1. You can see the status of the build in Gitlab CI. The location of that status is depending on your version. In the latest version Gitlab CI has been integrated in Gitlab.
  2. You need to place your .gitlab-ci.yml in the root path of your git repository. Furthermore, you need to make sure to give information in how to build the code in the .gitlab-ci.yml file. Please, have a look at my example above.