<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Gitlab for Devops Engineers]]></title><description><![CDATA[Gitlab for Devops Engineers]]></description><link>https://gitlab-pipeline.hashnode.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1735228653656/8370690b-a098-45d7-8b63-88272d5bccd9.png</url><title>Gitlab for Devops Engineers</title><link>https://gitlab-pipeline.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Mon, 31 Aug 2026 20:57:45 GMT</lastBuildDate><atom:link href="https://gitlab-pipeline.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Exploring GitLab Runners: A Beginner's Overview]]></title><description><![CDATA[In GitLab, runners are agents that run jobs in your CI/CD pipelines. They are used to execute the steps defined in your .gitlab-ci.yml file, such as running tests, deploying applications, or building containers. Here's a breakdown of key concepts and...]]></description><link>https://gitlab-pipeline.hashnode.dev/runners-in-gitlab</link><guid isPermaLink="true">https://gitlab-pipeline.hashnode.dev/runners-in-gitlab</guid><dc:creator><![CDATA[Satish Gore]]></dc:creator><pubDate>Wed, 25 Dec 2024 13:58:47 GMT</pubDate><content:encoded><![CDATA[<p>In GitLab, <strong>runners</strong> are agents that run jobs in your <strong>CI/CD pipelines</strong>. They are used to execute the steps defined in your <code>.gitlab-ci.yml</code> file, such as running tests, deploying applications, or building containers. Here's a breakdown of key concepts and usage of runners in GitLab:</p>
<h3 id="heading-key-concepts">Key Concepts:</h3>
<ol>
<li><p><strong><mark>GitLab Runner: This is an application that runs your CI/CD jobs. It can be installed on different systems such as Linux, macOS, or Windows, or even within Docker containers.</mark></strong></p>
</li>
<li><p><strong>Types of Runners</strong>:</p>
<ul>
<li><p><strong>Shared Runners</strong>: These are provided by GitLab and available to all projects on the instance. They are typically used for jobs that don't need a specific environment.</p>
</li>
<li><p><strong>Specific Runners</strong>: These are set up for specific projects or groups. A specific runner is tied to a particular project or group, and you can configure it with custom settings or resources.</p>
</li>
<li><p><strong>Group Runners</strong>: These are available to all projects within a specific GitLab group.</p>
</li>
</ul>
</li>
<li><p><strong>Runner Executors</strong>: The executor is the environment in which the job will run. Common executors include:</p>
<ul>
<li><p><strong>Shell</strong>: Executes jobs directly on the host machine's shell.</p>
</li>
<li><p><strong>Docker</strong>: Runs jobs inside a Docker container.</p>
</li>
<li><p><strong>Docker</strong>: Uses Docker Machine to create dynamic Docker containers for each job.</p>
</li>
<li><p><strong>Kubernetes</strong>: Runs jobs in a Kubernetes cluster.</p>
</li>
<li><p><strong>VirtualBox, Parallels, and others</strong>: Other executors exist that run jobs on virtual machines or other environments.</p>
</li>
</ul>
</li>
<li><p><strong>Job Execution</strong>: When a commit is made in a GitLab project, the runner listens for new jobs and picks them up to execute according to the instructions in the <code>.gitlab-ci.yml</code> file.</p>
</li>
</ol>
<p>how to create own runner:</p>
<p>download gitlab runner package</p>
<pre><code class="lang-yaml"><span class="hljs-string">curl</span> <span class="hljs-string">-L</span> <span class="hljs-string">"https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh"</span> <span class="hljs-string">|</span> <span class="hljs-string">sudo</span> <span class="hljs-string">bash</span>
</code></pre>
<p>install gitlab-runner</p>
<pre><code class="lang-yaml"><span class="hljs-string">sudo</span> <span class="hljs-string">apt</span> <span class="hljs-string">install</span> <span class="hljs-string">gitlab-runner</span>
</code></pre>
<ol>
<li><p>Go to <code>Settings</code> → <code>CI/CD</code>, in your project</p>
</li>
<li><p>Expand the <code>Runners</code> section</p>
</li>
<li><p>Select <code>New project runner</code></p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735207440417/80d1decd-a87d-4290-9fff-cdb91cb2be9d.png" alt class="image--center mx-auto" /></p>
<p>Enter the details and click on create runner</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735207588807/75e826cb-10af-40c8-8429-96938a82b3d3.png" alt class="image--center mx-auto" /></p>
<p>select the operating system</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735207663265/235979ad-5286-48a2-9e90-f37cbbee94f3.png" alt class="image--center mx-auto" /></p>
<p>then copy the token command and run it on runner Linux machine</p>
<pre><code class="lang-yaml"><span class="hljs-string">gitlab-runner</span> <span class="hljs-string">register</span>
  <span class="hljs-string">--url</span> <span class="hljs-string">https://gitlab.com</span>
  <span class="hljs-string">--token</span> <span class="hljs-string">glrt-t3_tpgWi1q2uWmBh6i2_q</span>
</code></pre>
<p><strong>Linux server terminal output</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735211304581/ccf48195-d056-42ed-a9fb-cb806f4c8b82.png" alt class="image--center mx-auto" /></p>
<p><strong>After that runner will connect to the GitLab server.</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735213008686/2d9edd16-ef19-4459-8922-9f15d3117f10.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-yaml"><span class="hljs-attr">stages:</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">build</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">test</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">deploy</span>

<span class="hljs-attr">variables:</span>
   <span class="hljs-attr">name:</span> <span class="hljs-string">"satish"</span>

<span class="hljs-attr">build_job:</span>
     <span class="hljs-attr">stage:</span> <span class="hljs-string">build</span>
     <span class="hljs-attr">script:</span>
       <span class="hljs-bullet">-</span> <span class="hljs-string">echo</span> <span class="hljs-string">"hello $name"</span>
       <span class="hljs-bullet">-</span> <span class="hljs-string">mkdir</span> <span class="hljs-string">logs</span>
       <span class="hljs-bullet">-</span> <span class="hljs-string">echo</span> <span class="hljs-string">"thiss are my result"</span> <span class="hljs-string">&gt;logs/app.log</span>
     <span class="hljs-attr">artifacts:</span>
       <span class="hljs-attr">paths:</span>
           <span class="hljs-bullet">-</span> <span class="hljs-string">logs/</span> 
       <span class="hljs-attr">expire_in:</span> <span class="hljs-number">30</span> <span class="hljs-string">days</span>


<span class="hljs-attr">test_job:</span>
     <span class="hljs-attr">stage:</span> <span class="hljs-string">test</span>
     <span class="hljs-attr">script:</span>
       <span class="hljs-bullet">-</span> <span class="hljs-string">echo</span> <span class="hljs-string">"helloo $name"</span>
     <span class="hljs-attr">tags:</span>
       <span class="hljs-bullet">-</span> <span class="hljs-string">my-runner</span>


<span class="hljs-attr">deploy_job:</span>
     <span class="hljs-attr">stage:</span> <span class="hljs-string">deploy</span>
     <span class="hljs-attr">script:</span>
       <span class="hljs-bullet">-</span> <span class="hljs-string">echo</span> <span class="hljs-string">"heello $name"</span>
</code></pre>
<p><strong>using tags we can select the runner. here I am using my-runner tag to use newly created runner.</strong></p>
<pre><code class="lang-yaml"><span class="hljs-attr">test_job:</span>
     <span class="hljs-attr">stage:</span> <span class="hljs-string">test</span>
     <span class="hljs-attr">script:</span>
       <span class="hljs-bullet">-</span> <span class="hljs-string">echo</span> <span class="hljs-string">"hello $name"</span>
     <span class="hljs-attr">tags:</span>
       <span class="hljs-bullet">-</span> <span class="hljs-string">my-runner</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735212786464/38adfec5-9382-467f-9001-ec8be8fc07e0.png" alt class="image--center mx-auto" /></p>
<p><strong>test job completed using my-runner</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735212855658/8b85014e-8601-4bc1-99cb-6b6126b67fcd.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Basics of Gitlab CICD]]></title><description><![CDATA[GitLab Pipeline Overview
A GitLab pipeline is a powerful automation feature that helps automate the continuous integration and continuous delivery (CI/CD) process for your code. It defines a series of stages and jobs that execute in a predefined sequ...]]></description><link>https://gitlab-pipeline.hashnode.dev/basics-of-gitlab-cicd</link><guid isPermaLink="true">https://gitlab-pipeline.hashnode.dev/basics-of-gitlab-cicd</guid><dc:creator><![CDATA[Satish Gore]]></dc:creator><pubDate>Tue, 24 Dec 2024 06:07:17 GMT</pubDate><content:encoded><![CDATA[<h3 id="heading-gitlab-pipeline-overview">GitLab Pipeline Overview</h3>
<p>A <strong>GitLab pipeline</strong> is a powerful automation feature that helps automate the continuous integration and continuous delivery (CI/CD) process for your code. It defines a series of stages and jobs that execute in a predefined sequence, ensuring that your code is tested, built, and deployed efficiently.</p>
<p>Pipelines in GitLab are defined using a configuration file called <code>.gitlab-ci.yml</code>, which is stored in the root directory of the repository. The <code>.gitlab-ci.yml</code> file describes how the pipeline should run, including the jobs, stages, and scripts to be executed.</p>
<h3 id="heading-key-concepts-of-gitlab-pipelines">Key Concepts of GitLab Pipelines</h3>
<ol>
<li><p><strong>Pipeline</strong>:</p>
<ul>
<li>A pipeline is a collection of jobs organized into stages. A pipeline is triggered every time changes are made to the repository.</li>
</ul>
</li>
<li><p><strong>Stages</strong>:</p>
<ul>
<li><p>Stages are the different steps in the pipeline. Each stage consists of one or more jobs that are executed concurrently, and once all jobs in a stage finish, the next stage begins.</p>
</li>
<li><p>Typical stages include:</p>
<ul>
<li><p><strong>Build</strong>: Compiling code or preparing assets.</p>
</li>
<li><p><strong>Test</strong>: Running unit, integration, and other tests.</p>
</li>
<li><p><strong>Deploy</strong>: Deploying the application to different environments (e.g., staging, production).</p>
</li>
</ul>
</li>
</ul>
</li>
<li><p><strong>Jobs</strong>:</p>
<ul>
<li><p>Jobs are the individual units of work in a pipeline. Each job runs a specific command or script (e.g., <code>npm install</code>, <code>python</code> <a target="_blank" href="http://test.py"><code>test.py</code></a>, <code>docker build</code>).</p>
</li>
<li><p>Jobs are executed on GitLab <strong>Runners</strong>, which are agents responsible for running the jobs.</p>
</li>
</ul>
</li>
<li><p><strong>GitLab Runners</strong>:</p>
<ul>
<li><strong>GitLab Runners</strong> are agents that run the jobs defined in the pipeline. They can be shared (available for all projects) or specific to a particular project or group.</li>
</ul>
</li>
<li><p><strong>Artifacts</strong>:</p>
<ul>
<li>Artifacts are files generated by jobs (e.g., test results, compiled code, documentation) that are passed between stages or saved for later use.</li>
</ul>
</li>
<li><p><strong>Dependencies</strong>:</p>
<ul>
<li>Jobs can depend on other jobs to run. This is managed using <strong>dependencies</strong> and ensures that a job only runs after certain jobs have completed successfully.</li>
</ul>
</li>
</ol>
<p><img src="https://miro.medium.com/v2/resize:fit:700/1*3stkQyMCIZHjDII0dUOaJw.png" alt /></p>
<h3 id="heading-step-1-create-a-new-gitlab-project">Step 1: Create a New GitLab Project</h3>
<ol>
<li><p><strong>Log in to GitLab</strong>: Go to your GitLab instance and log in with your credentials.</p>
</li>
<li><p><strong>Create a New Project</strong>:</p>
<ul>
<li><p>On the GitLab dashboard, click the <code>New project</code> button.</p>
</li>
<li><p>Choose the type of project (e.g., <strong>Blank project</strong>).</p>
</li>
<li><p>Fill in the necessary details such as:</p>
<ul>
<li><p><strong>Project name</strong>: Choose a name for your project.</p>
</li>
<li><p><strong>Visibility level</strong>: Select whether you want the project to be <strong>Private</strong>, <strong>Internal</strong>, or <strong>Public</strong>.</p>
</li>
</ul>
</li>
<li><p>Click <strong>Create project</strong>.</p>
</li>
</ul>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735021087756/9c0bda6a-31d7-47f4-a9cf-9742af795ca9.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735021178610/adde76cf-6b16-45d9-a790-cfcdd5715bf1.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735021280208/e54499c0-4c04-4340-bc63-058aa0ced8df.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-step-2-set-up-a-gitlab-ci-pipeline-configuration-gitlab-ciyml">Step 2: Set Up a GitLab CI Pipeline Configuration (<code>.gitlab-ci.yml</code>)</h3>
<ol>
<li><p><strong>Navigate to your project</strong>: Once the project is created, you'll be taken to the project’s repository page.</p>
</li>
<li><p><strong>Create the</strong> <code>.gitlab-ci.yml</code> file:</p>
<ul>
<li>In the root directory of your project, create a file named <code>.gitlab-ci.yml</code>. This file contains the configuration for your CI pipeline.</li>
</ul>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735102753276/62a95346-e28c-4756-b336-61c29cc71f7b.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-step-3-commit-the-gitlab-ciyml-file-to-your-repository">Step 3: Commit the <code>.gitlab-ci.yml</code> File to Your Repository</h3>
<ol>
<li><p><strong>Commit the</strong> <code>.gitlab-ci.yml</code> file:</p>
<ul>
<li>Once the <code>.gitlab-ci.yml</code> file is created, commit it to your GitLab repository.</li>
</ul>
</li>
</ol>
<ol>
<li><strong>Job 3</strong>: <code>deploy</code>, which depends on <code>test</code> and also stores artifacts</li>
</ol>
<pre><code class="lang-yaml">    <span class="hljs-attr">yamlCopy codestages:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">build</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">test</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">deploy</span>

    <span class="hljs-comment"># Job to build the project</span>
    <span class="hljs-attr">build:</span>
      <span class="hljs-attr">stage:</span> <span class="hljs-string">build</span>
      <span class="hljs-attr">script:</span>
        <span class="hljs-bullet">-</span> <span class="hljs-string">echo</span> <span class="hljs-string">"Building the project..."</span>
        <span class="hljs-bullet">-</span> <span class="hljs-string">mkdir</span> <span class="hljs-string">build_output</span>
        <span class="hljs-bullet">-</span> <span class="hljs-string">echo</span> <span class="hljs-string">"Build successful"</span> <span class="hljs-string">&gt;</span> <span class="hljs-string">build_output/build.log</span>
      <span class="hljs-attr">artifacts:</span>
        <span class="hljs-attr">paths:</span>
          <span class="hljs-bullet">-</span> <span class="hljs-string">build_output/</span>
        <span class="hljs-attr">expire_in:</span> <span class="hljs-number">1</span> <span class="hljs-string">hour</span>

    <span class="hljs-comment"># Job to test the project</span>
    <span class="hljs-attr">test:</span>
      <span class="hljs-attr">stage:</span> <span class="hljs-string">test</span>
      <span class="hljs-attr">needs:</span> 
        <span class="hljs-bullet">-</span> <span class="hljs-attr">job:</span> <span class="hljs-string">build</span>
          <span class="hljs-attr">artifact:</span> <span class="hljs-literal">true</span>
      <span class="hljs-attr">script:</span>
        <span class="hljs-bullet">-</span> <span class="hljs-string">echo</span> <span class="hljs-string">"Running tests..."</span>
        <span class="hljs-bullet">-</span> <span class="hljs-string">cat</span> <span class="hljs-string">build_output/build.log</span>
        <span class="hljs-bullet">-</span> <span class="hljs-string">echo</span> <span class="hljs-string">"Test passed"</span>
      <span class="hljs-attr">artifacts:</span>
        <span class="hljs-attr">paths:</span>
          <span class="hljs-bullet">-</span> <span class="hljs-string">test_reports/</span>
        <span class="hljs-attr">expire_in:</span> <span class="hljs-number">2</span> <span class="hljs-string">hours</span>

    <span class="hljs-comment"># Job to deploy the project</span>
    <span class="hljs-attr">deploy:</span>
      <span class="hljs-attr">stage:</span> <span class="hljs-string">deploy</span>
      <span class="hljs-attr">needs:</span>
        <span class="hljs-bullet">-</span> <span class="hljs-attr">job:</span> <span class="hljs-string">test</span>
          <span class="hljs-attr">artifact:</span> <span class="hljs-literal">true</span>
      <span class="hljs-attr">script:</span>
        <span class="hljs-bullet">-</span> <span class="hljs-string">echo</span> <span class="hljs-string">"Deploying the project..."</span>
        <span class="hljs-bullet">-</span> <span class="hljs-string">cat</span> <span class="hljs-string">test_reports/test_report.txt</span>
        <span class="hljs-bullet">-</span> <span class="hljs-string">echo</span> <span class="hljs-string">"Deployment completed"</span>
      <span class="hljs-attr">artifacts:</span>
        <span class="hljs-attr">paths:</span>
          <span class="hljs-bullet">-</span> <span class="hljs-string">deploy_logs/</span>
        <span class="hljs-attr">expire_in:</span> <span class="hljs-number">1</span> <span class="hljs-string">day</span>
</code></pre>
<h3 id="heading-step-4-trigger-the-ci-pipeline">Step 4: Trigger the CI Pipeline</h3>
<ol>
<li><p><strong>Push Changes to GitLab</strong>: Whenever you push the <code>.gitlab-ci.yml</code> file to your repository (or any other change), GitLab will automatically detect the presence of the <code>.gitlab-ci.yml</code> file and trigger the pipeline.</p>
<ul>
<li>After you push the changes, go to the <strong>CI / CD</strong> section of the project, which can be found in the left sidebar under <strong>CI / CD</strong>.</li>
</ul>
</li>
<li><p><strong>Pipeline Started</strong>: You’ll see the pipeline is triggered and will move through the defined stages. If the pipeline doesn't trigger automatically, ensure that <code>.gitlab-ci.yml</code> is properly formatted and committed.</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735103272257/463f6860-99c3-4585-bafe-0ad52f4ecd3d.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-step-5-monitor-ci-pipeline-jobs">Step 5: Monitor CI Pipeline Jobs</h3>
<ol>
<li><p><strong>Navigate to the Pipelines Page</strong>:</p>
<ul>
<li><p>In your project, go to the <strong>CI / CD</strong> section from the left sidebar.</p>
</li>
<li><p>Click on <strong>Pipelines</strong>. This will show you a list of all pipelines for the project.</p>
</li>
<li><p>You’ll see the pipeline with a status indicating whether it's <strong>running</strong>, <strong>succeeded</strong>, or <strong>failed</strong>.</p>
</li>
</ul>
</li>
<li><p><strong>View Job Details</strong>:</p>
<ul>
<li><p>Click on the pipeline entry to see detailed information about each job.</p>
</li>
<li><p>You will be able to see:</p>
<ul>
<li><p>The status of each job (success, failed, canceled, etc.).</p>
</li>
<li><p>Logs for each job by clicking on the job name (e.g., <code>build</code>, <code>test</code>, <code>deploy</code>).</p>
</li>
<li><p>Artifacts that were created during each job.</p>
</li>
</ul>
</li>
</ul>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735103302525/6c41f0b9-f91c-4adc-af2a-dfeec9c9747b.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735103338065/47eccfa9-c771-45d0-8774-1fbddc29e50a.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735105472028/c8030c95-7aad-41ed-a868-f79e959d928e.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item></channel></rss>