(Created page with "== Pipeline Configuration File == GitLab CI/CD build for a repository are controlled placing a file named '''.gitlab_ci.yml''' in the root folder of the repository. The expec...")
 
No edit summary
Line 1: Line 1:
== Pipeline Configuration File ==
= Pipeline Configuration File =


GitLab CI/CD build for a repository are controlled placing a file named '''.gitlab_ci.yml''' in the root folder of the repository. The expected content of the file is specified on GitLab's
GitLab CI/CD build for a repository are controlled placing a file named '''.gitlab_ci.yml''' in the root folder of the repository. The expected content of the file is specified on GitLab's
[https://docs.gitlab.com/ee/ci/yaml/gitlab_ci_yaml.html gitlab_ci.yml Documentation page].
[https://docs.gitlab.com/ee/ci/yaml/gitlab_ci_yaml.html gitlab_ci.yml Documentation page].


== GitLab Runner ==
= GitLab Runner =


== Installing ==
Follow the instructions on [https://docs.gitlab.com/runner/install/ this GitLab documentation page], summarized below, where you set up a user account for GitLab Runner and make it launch automatically when your system starts.
<pre class="terminal">
sudo curl -L --output /usr/local/bin/gitlab-runner "https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64"
sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
sudo gitlab-runner start
</pre>
You can check the status of the service by typing
<pre class="terminal">
sudo gitlab-runner status
</pre>
<br />
== Using with Docker ==
If GitLab Runner is to build your software inside of [[Docker]] containers, it needs to able to issue Docker commands. Therefore, make sure Docker is installed and the user ''gitlab-runner'' is a member of the ''docker'' group:
<pre class="terminal">
sudo usermod -aG docker gitlab-runner
</pre>
which, in virtualized Linux environments, may require a reboot to take effect.
<br />
<br />
The integration of GitLab Runner with Docker goes deeper than just instantiating a container:
Before launching the build scripts from ''.gitlab_ci.yml'', GitLab Runner will clone the repository
into a build folder inside the container! The default path is ''/build/'' followed by the project path
on the GitLab server. The build scripts simply leave it to GitLab Runner to provide them with the
correct commit from the correct branch.
<br />
<br />
== Registering the Runner ==
After GitLab Runner is installed, you will need to register the runner with the GitLab code repository. Typing
<pre class="terminal">
sudo gitlab-runner register
</pre>
launches the interactive registration, which will prompt you for each of the configuration parameters. You can also supply some or all of the parameters directly in the command:
<pre class="terminal">
sudo gitlab-runner register \
  --url "https://" \
  --registration-token <secret token> \
  --description "docker-swift:5.4" \
  --executor "docker" \
  --docker-image swift:5.4
</pre>
where ''<secret token>'' is the token obtained from GitLab project settings &rarr; ''CI/CD'' &rarr; ''Runners'' &rarr; ''Specific Runners''.
<br />
<br />
Registration finishes by generating the '''/etc/gitlab-runner/config.toml''' file similar to this:
<pre class="code">
concurrent = 1
check_interval = 0


== Creating a Product Release ==
[session_server]
  session_timeout = 1800
 
[[runners]]
  name = "ubuntu-at-home"
  url = "https://gitlab.com/"
  token = <secret token>
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "keytree"
    privileged = false
    disable_entrypoint_overwrite = false
    pull_policy = "never"
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0
</pre>
after which, the ''gitlab-runner'' service will notice that the configuration file has changed and applies the new configuration.
<br />
<br />
Note that the '''pull_policy''' option was explicitly set to "never" instead of going with the default "always". This prevents GitLab Runner from searching for the specified Docker image on [https://hub.docker.com Docker Hub] and directs the query to the local docker engine!
 
 
= How To Create A Product Release =

Revision as of 2021-06-23T18:02:52

Pipeline Configuration File

GitLab CI/CD build for a repository are controlled placing a file named .gitlab_ci.yml in the root folder of the repository. The expected content of the file is specified on GitLab's gitlab_ci.yml Documentation page.

GitLab Runner

Installing

Follow the instructions on this GitLab documentation page, summarized below, where you set up a user account for GitLab Runner and make it launch automatically when your system starts.

sudo curl -L --output /usr/local/bin/gitlab-runner "https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64"
sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
sudo gitlab-runner start

You can check the status of the service by typing

sudo gitlab-runner status


Using with Docker

If GitLab Runner is to build your software inside of Docker containers, it needs to able to issue Docker commands. Therefore, make sure Docker is installed and the user gitlab-runner is a member of the docker group:

sudo usermod -aG docker gitlab-runner

which, in virtualized Linux environments, may require a reboot to take effect.

The integration of GitLab Runner with Docker goes deeper than just instantiating a container: Before launching the build scripts from .gitlab_ci.yml, GitLab Runner will clone the repository into a build folder inside the container! The default path is /build/ followed by the project path on the GitLab server. The build scripts simply leave it to GitLab Runner to provide them with the correct commit from the correct branch.

Registering the Runner

After GitLab Runner is installed, you will need to register the runner with the GitLab code repository. Typing

sudo gitlab-runner register

launches the interactive registration, which will prompt you for each of the configuration parameters. You can also supply some or all of the parameters directly in the command:

sudo gitlab-runner register \
  --url "https://" \
  --registration-token <secret token> \
  --description "docker-swift:5.4" \
  --executor "docker" \
  --docker-image swift:5.4

where <secret token> is the token obtained from GitLab project settings → CI/CDRunnersSpecific Runners.

Registration finishes by generating the /etc/gitlab-runner/config.toml file similar to this:

concurrent = 1 
check_interval = 0 

[session_server]
  session_timeout = 1800

[[runners]]
  name = "ubuntu-at-home"
  url = "https://gitlab.com/"
  token = <secret token>
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "keytree"
    privileged = false
    disable_entrypoint_overwrite = false
    pull_policy = "never"
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0 

after which, the gitlab-runner service will notice that the configuration file has changed and applies the new configuration.

Note that the pull_policy option was explicitly set to "never" instead of going with the default "always". This prevents GitLab Runner from searching for the specified Docker image on Docker Hub and directs the query to the local docker engine!


How To Create A Product Release


Debug data: