Gitlab getting started

Add you ssh key to gitlab user > profile > preferences

on command line run ssh-agent and ssh-add ~/path/to/sshkey

run ssh git@gitlab.com to verify your sshkey is working or not for authentication

To use GitLab CI/CD, you need:

  • Application code hosted in a Git repository.

  • A file called .gitlab-ci.yml in the root of your repository, which contains the CI/CD configuration.

In the .gitlab-ci.yml file, you can define:

  • The scripts you want to run.

  • Other configuration files and templates you want to include.

  • Dependencies and caches.

  • The commands you want to run in sequence and those you want to run in parallel.

  • The location to deploy your application to.

  • Whether you want to run the scripts automatically or trigger any of them manually.

In GitLab CI/CD, an artifact is a file or a collection of files generated by a job that can be passed to other jobs for further processing, or be stored for later use.

You can define artifacts in the .gitlab-ci.yml configuration file by specifying the path to the files you want to include as artifacts. Here I want to keep the directory named "build" and its contents. (Check yaml syntax as its easy to break the pipeline due to spaces)

stages:
  - build
  - test
build the car:
  stage: build
  script:
    - mkdir build
    - cd build
    - touch car.txt
    - echo "chasis" > car.txt
    - echo "engine" >> car.txt
    - echo "wheel" >> car.txt
  artifacts:
    paths:
      - build/
test the car:
  stage: test
  script:
    - test -f build/car.txt
    - grep "engine" build/car.txt
    - grep "chasis" build/car.txt

Gitlab server gives interface allow to create repository, manage every thing related to project, every thing we do is saved to db after pipeline is created it will be managed by gitlab server but will get delegated to gitlab RUNNER. The Runners can be one or more(can be increased/decreased) and scalable according to need (scalable) and it does all the heavy lifting/tasks. Succinctly,a GitLab Runner is an application that works with GitLab CI/CD to run jobs in a pipeline.