Gitlab - Job

  • Introducció

    Pots configurar Gitlab per tal que quan actualitzes un projecte també s’executi un treball dins un Docker - Contenidor.

    Entorn de treball

    Crea un repositori a gitlab tal com s’explica a Gitlab - Repositori.

    Clona el projecte a la maquina local.

    Afegeix un fitxer .gitlab-ci.yml al projecte.

    test:
    script:
    - echo "Hello, World!" > hello.txt
    - ls -la

    Fes un

    Hosted Runners

    All your CI/CD jobs run on n1-standard-1 instances with 3.75GB of RAM, CoreOS and the latest Docker Engine installed. Instances provide 1 vCPU and 25GB of HDD disk space.

    You can also confirm these stats real-time by adding a few commands to a GitLab CI job.

    shared-runner-stats:
    script:
    - free -m | grep -v "Swap" # RAM
    - df -h| grep -E "Filesystem|overlay" # storage
    - lscpu | grep -E "^CPU\(s\)" # CPUs

    The output should look something like:

    Terminal window
    $ free -m | grep -v "Swap"
    total used free shared buff/cache available
    Mem: 3693 481 2221 199 991 2790
    $ df -h| grep -E "Filesystem|overlay"
    Filesystem Size Used Avail Use% Mounted on
    overlay 22G 4.6G 17G 22% /
    $ lscpu | grep -E "^CPU\(s\)"
    CPU(s):

    Service

    When you configure CI/CD, you specify an image, which is used to create the container where your jobs run. To specify this image, you use the image keyword.

    You can specify an additional image by using the services keyword. This additional image is used to create another container, which is available to the first container. The two containers have access to one another and can communicate when running the job.

    The service image can run any application, but the most common use case is to run a database container.

    You’re not limited to only database services. You can add as many services you need to .gitlab-ci.yml or manually modify the config.toml. Any image found at Docker Hub or your private container registry can be used as a service.

    Services inherit the same DNS servers, search domains, and additional hosts as the CI container itself.

    Jobs - Services

    Postgres

    As many applications depend on Postgres as their database, you have to use it to run your tests.

    TODO