<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Arnav</title>
    <description>The latest articles on DEV Community by Arnav (@arnavgit923).</description>
    <link>https://dev.to/arnavgit923</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4091014%2F5cfb9c47-20b4-4d72-a3f2-b9fe98907b40.jpg</url>
      <title>DEV Community: Arnav</title>
      <link>https://dev.to/arnavgit923</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arnavgit923"/>
    <language>en</language>
    <item>
      <title>The GitLab CI Manual: The Textbook You’ve Always Needed — #2 Basic CI Coverage</title>
      <dc:creator>Arnav</dc:creator>
      <pubDate>Wed, 04 Nov 2026 09:52:22 +0000</pubDate>
      <link>https://dev.to/arnavgit923/the-gitlab-ci-manual-the-textbook-youve-always-needed-2-basic-ci-coverage-236c</link>
      <guid>https://dev.to/arnavgit923/the-gitlab-ci-manual-the-textbook-youve-always-needed-2-basic-ci-coverage-236c</guid>
      <description>&lt;p&gt;The second post in the 5-part series will aim to provide a clear and distinct understanding on the following topics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Anatomy of CI Jobs&lt;/li&gt;
&lt;li&gt;Stages in Jobs&lt;/li&gt;
&lt;li&gt;Job Rules &amp;amp; Dependencies&lt;/li&gt;
&lt;li&gt;Job Inputs&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before kicking things off, a few prerequisites are needed and will be required for the remainder of this series.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A GitLab account&lt;/li&gt;
&lt;li&gt;A GitLab repository&lt;/li&gt;
&lt;li&gt;A basic understanding on YAML (which can be learned here: &lt;a href="https://youtu.be/IA90BTozdow?si=y8MFH7nwBif2RVni" rel="noopener noreferrer"&gt;https://youtu.be/IA90BTozdow?si=y8MFH7nwBif2RVni&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  CI Jobs — The mechanical organs of a pipeline
&lt;/h2&gt;

&lt;p&gt;CI jobs are the mechanical instruments that are used to execute script commands. By script commands, we mean commands normally executed in, say, a *&lt;a href="https://www.coursera.org/articles/command-line-interface" rel="noopener noreferrer"&gt;CLI&lt;/a&gt; such as &lt;code&gt;cmd&lt;/code&gt;, &lt;code&gt;bash&lt;/code&gt;, &lt;code&gt;docker&lt;/code&gt;, &lt;code&gt;kubectl&lt;/code&gt;, &lt;code&gt;mongo&lt;/code&gt;. Plain and simple.&lt;/p&gt;

&lt;p&gt;Jobs in a CI/CD pipeline contain a job name, along with the script keyword, which facilitates the execution of script commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;first_script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "This is a script!"&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "These commands run inside this script."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;first_script&lt;/code&gt;: The job’s name. Of course, a job can have any name, other than the glaringly-obvious reserved CI keywords that will be discussed much later in this series.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;script&lt;/code&gt;: The keyword used to run commands in a *&lt;a href="https://medium.com/@caring_smitten_gerbil_914/understanding-the-shell-environment-in-linux-a-complete-guide-with-real-world-examples-76108b57c43d" rel="noopener noreferrer"&gt;shell environment&lt;/a&gt;. This is a very crucial point to remember, and is expanded upon in later sections of this post.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;CI Jobs and Shell Environments&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Each job in a CI/CD pipeline runs in a shell environment. These environments are non-interactive in nature, meaning that the user cannot interact with them, as they normally would in a regular CLI, such as setting global users for Git repositories using &lt;code&gt;git config --global user.(name|email)&lt;/code&gt;. Running interactive commands in a job result in the pipeline being stuck, due to the absence of *&lt;a href="https://en.wikipedia.org/wiki/Tty_(Unix)" rel="noopener noreferrer"&gt;TTY&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;All jobs execute script commands in the same shell environment. There are some script commands that, despite being in the same job, run in different shell environments.&lt;/p&gt;

&lt;p&gt;On this basis, we have 3 distinct keywords that dictate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The order in which the script commands in a job are run&lt;/li&gt;
&lt;li&gt;The distinction between each script’s shell environment&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;CI Keyword&lt;/th&gt;
&lt;th&gt;Primary Purpose&lt;/th&gt;
&lt;th&gt;Same Shell Environment?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;before_script&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Runs script commands before the main script&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;script&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Runs main script commands&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;after_script&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Runs script commands after the main script commands&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code&gt;after_script&lt;/code&gt; job will always run after the &lt;code&gt;main&lt;/code&gt; script, whether or not the &lt;code&gt;main&lt;/code&gt; script or the &lt;code&gt;before_script&lt;/code&gt; passed.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: Any variables set inside the &lt;code&gt;before_script&lt;/code&gt; and script jobs WILL NOT carry over to the &lt;code&gt;after_script&lt;/code&gt; job.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Stages in Jobs&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Jobs in a pipeline run in-parallel by default. In order to run them sequentially — one after another, that is — we use stages.&lt;/p&gt;

&lt;p&gt;Stages in a pipeline allow jobs to run sequentially. A stage can contain a number of jobs, but a job can only be in one stage.&lt;/p&gt;

&lt;p&gt;CI/CD pipelines provide two keywords for this concept:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;stages&lt;/code&gt;: A global keyword to define stages in a job.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;stage&lt;/code&gt;: A job-level keyword to declare a job inside a stage.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# global keyword&lt;/span&gt;
&lt;span class="na"&gt;stages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;push&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;deploy&lt;/span&gt;

&lt;span class="na"&gt;build_image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="c1"&gt;# job-level keyword&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "Building Docker image..."&lt;/span&gt;

&lt;span class="na"&gt;push_image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;push&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "Pushing Docker image to Git Repository..."&lt;/span&gt;

&lt;span class="na"&gt;deploy_image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;deploy&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "Deploying to AWS..."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: All jobs in a pipeline run inside the test stage, if stages are not defined in a pipeline.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;job_1&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "This is job 1."&lt;/span&gt;

&lt;span class="na"&gt;job_2&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "This is job 2."&lt;/span&gt;

&lt;span class="na"&gt;job_3&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "This is job 3."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuau92p6yw49ogoj4st4q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuau92p6yw49ogoj4st4q.png" alt=" " width="375" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A few features of stages are provided below&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;By default, for a pipeline to advance forward, all jobs in a stage must succeed. If one job fails, the succeeding stages do not run and the pipeline halts, unless explicitly written.&lt;/li&gt;
&lt;li&gt;Stages run sequentially in the order they are defined.&lt;/li&gt;
&lt;li&gt;When stages are declared in a pipeline, every job MUST be included in a stage!&lt;/li&gt;
&lt;li&gt;Jobs in a stage run in-parallel with each other.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Jobs Rules &amp;amp; Dependencies
&lt;/h3&gt;

&lt;p&gt;Rules dictate the overall flow of jobs — when do they start, if they start at all, and are jobs in a stage allowed to fail so that other stages can run.&lt;/p&gt;

&lt;p&gt;Dependencies, on the other hand, inject a *&lt;a href="https://en.wikipedia.org/wiki/Directed_acyclic_graph" rel="noopener noreferrer"&gt;DAG&lt;/a&gt;-like relationship between jobs. Jobs do not execute unless the required job is successfully executed first.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dictating the flow of jobs — Job Rules
&lt;/h3&gt;

&lt;p&gt;We can use the rules keyword to inject rules in a pipeline for jobs.&lt;/p&gt;

&lt;p&gt;The rules keyword comes with its own set of sub-keywords:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;rules:if&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;rules:when&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;rules:exists&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;rules:allow_failure&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;rules:changes&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  1. Configure when jobs run based on conditions — &lt;code&gt;rules:if&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;rules:if&lt;/code&gt; keyword adds each job to a pipeline based on the first match found.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If at-least one match from the list of if conditions is found (the first match), the rest are ignored and the job is added to the pipeline.&lt;/li&gt;
&lt;li&gt;If no if condition matches, then the job is ignored.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;variables&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;allowed_to_run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;

&lt;span class="na"&gt;job_with_rules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "This job has rules and will execute&lt;/span&gt; 
       &lt;span class="s"&gt;based on the first match found to be &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="s"&gt;."&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;$allowed_to_run&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;true'&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;$CI_COMMIT_BRANCH&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;$CI_DEFAULT_BRANCH'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, we have 2 rules on the satisfaction of which, the job is added to the pipeline.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first rule is checked and it is found that the condition is not satisfied.&lt;/li&gt;
&lt;li&gt;The second rule is checked, the condition is satisfied, and the job is added to the pipeline.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Note: CI/CD variables will be discussed much later in the series. For now, consider the above example to be intuitively understood.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Configure when jobs run based on number of satisfied conditions — &lt;code&gt;rules:when&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;When the &lt;code&gt;when:&lt;/code&gt; keyword is combined with the &lt;code&gt;rules:&lt;/code&gt; keyword, it changes the behaviour of the job:&lt;/p&gt;

&lt;p&gt;If any ONE if condition is satisfied in a job, the pipeline then evaluates the when keyword.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;deploy_to_aws&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "Deploying to AWS..."&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;$CI_COMMIT_BRANCH&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;$CI_DEFAULT_BRANCH'&lt;/span&gt;
      &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;manual&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The condition is checked, and is satisfied.&lt;/li&gt;
&lt;li&gt;The job is then configured to run manually in the GitLab UI.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  3. Configure when jobs run based on existence of files — &lt;code&gt;rules:exists&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;The way &lt;code&gt;rules:exists&lt;/code&gt; keyword works is — if the specified file (or a path to the file) exists, then the job is added to the pipeline. Otherwise, it will not run.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;deploy_to_aws&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "Deploying to AWS..."&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;$CI_COMMIT_BRANCH&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;$CI_DEFAULT_BRANCH'&lt;/span&gt;
      &lt;span class="na"&gt;exists&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Dockerfile"&lt;/span&gt;
      &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;manual&lt;/span&gt; &lt;span class="c1"&gt;# job is required to run manually if Dockerfile exists&lt;/span&gt;

    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;$CI_COMMIT_BRANCH&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;$CI_DEFAULT_BRANCH'&lt;/span&gt;
      &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;on_success&lt;/span&gt;  &lt;span class="c1"&gt;# runs if the file does not exist&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  4. Configure jobs to allow them to fail — &lt;code&gt;rules:allow_failure&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;When the &lt;code&gt;allow_failure:&lt;/code&gt; keyword is used with the &lt;code&gt;rules:&lt;/code&gt; keyword, it modifies the behaviour of the keyword.&lt;/p&gt;

&lt;p&gt;If one match from the pool of if keywords is found, the pipeline then evaluates the &lt;code&gt;allow_failure&lt;/code&gt; keyword.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;test_job&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "Testing build..."&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;$CI_COMMIT_BRANCH&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;$CI_DEFAULT_BRANCH'&lt;/span&gt;
      &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;on_success&lt;/span&gt;
      &lt;span class="na"&gt;allow_failure&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="c1"&gt;# test job runs for main branch and is allowed&lt;/span&gt;
                          &lt;span class="c1"&gt;# to fail&lt;/span&gt;

    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;on_success&lt;/span&gt;
      &lt;span class="na"&gt;allow_failure&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="c1"&gt;# test job runs on success and (if) fails for&lt;/span&gt;
                           &lt;span class="c1"&gt;# every other branch to fix errors&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  5. Configure jobs to run based on file changes — &lt;code&gt;rules:changes&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;Changes made to any file (or number of files) in a repository can trigger a pipeline to run when the rules:changes keyword is used.&lt;/p&gt;

&lt;p&gt;The files and their absolute paths specified inside this keyword can be kept track off for any changes made by the developers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;deploy_to_aws&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "Deploying to AWS..."&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;manual&lt;/span&gt;
      &lt;span class="na"&gt;changes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;Dockerfile&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;docker-compose.yml&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Injecting dependencies — Job Dependencies
&lt;/h3&gt;

&lt;p&gt;Some jobs depend on other jobs’ completion in order for those jobs to run. This is where job dependencies come into play.&lt;/p&gt;

&lt;p&gt;Job Dependencies can be injected in a pipeline using the &lt;code&gt;needs:&lt;/code&gt; keyword.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;stages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;test&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;deploy&lt;/span&gt;

&lt;span class="na"&gt;build_stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "Building Dockerfile..."&lt;/span&gt;

&lt;span class="na"&gt;test_stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;test&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "Testing build..."&lt;/span&gt;
  &lt;span class="na"&gt;needs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;build_stage"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# for main branch, allow it to fail&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;$CI_COMMIT_BRANCH&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;$CI_DEFAULT_BRANCH'&lt;/span&gt;
      &lt;span class="na"&gt;allow_failure&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;

    &lt;span class="c1"&gt;# for other branches, it will always run&lt;/span&gt;
    &lt;span class="c1"&gt;# allow it to fail for error-checking&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;always&lt;/span&gt;
      &lt;span class="na"&gt;allow_failure&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;

&lt;span class="na"&gt;deploy_stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;deploy&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "Deploying to AWS..."&lt;/span&gt;
  &lt;span class="na"&gt;needs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;build_stage"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# manual deployment from main branch&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;$CI_COMMIT_BRANCH&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;$CI_DEFAULT_BRANCH'&lt;/span&gt;
      &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;manual&lt;/span&gt;
      &lt;span class="na"&gt;changes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;.gitlab-ci.yml&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What’s happening inside the example&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;3 jobs were defined — &lt;code&gt;build_stage&lt;/code&gt;, &lt;code&gt;test_stage&lt;/code&gt;, &lt;code&gt;deploy_stage&lt;/code&gt; — inside 3 stages — &lt;code&gt;build&lt;/code&gt;, &lt;code&gt;test&lt;/code&gt;, &lt;code&gt;deploy&lt;/code&gt;, respectively.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;test_stage&lt;/code&gt; needs &lt;code&gt;build_stage&lt;/code&gt; to execute successfully. It has two conditions — &lt;strong&gt;(A)&lt;/strong&gt; If commit happens on the main branch, then add the job to the pipeline and allow it to fail; &lt;strong&gt;(B)&lt;/strong&gt; If the commit happens on any other branch → job is added to the pipeline → it always runs and is allowed to fail.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;deploy_stage&lt;/code&gt; needs &lt;code&gt;build_stage&lt;/code&gt; to execute successfully, as well.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The DAG-like dependency injected on these jobs looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F449oeadpe5bwl73q2myx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F449oeadpe5bwl73q2myx.png" alt=" " width="681" height="469"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: Try using &lt;code&gt;needs:&lt;/code&gt; inside &lt;code&gt;rules:&lt;/code&gt;. Note the differences you see between &lt;strong&gt;static job dependency&lt;/strong&gt; (standalone &lt;code&gt;needs:&lt;/code&gt; ) and &lt;strong&gt;dynamic job dependency&lt;/strong&gt; (&lt;code&gt;rules:needs&lt;/code&gt;).&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Job Inputs
&lt;/h2&gt;

&lt;p&gt;Inputs in jobs allow for typed validated parameters that can be overridden with new values when retrying or manually running jobs.&lt;/p&gt;

&lt;p&gt;The main difference between jobs inputs and job variables is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inputs allow for typed checks&lt;/li&gt;
&lt;li&gt;Variables remove hard-coded values from pipelines altogether.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Note: &lt;strong&gt;CI/CD pipeline configuration inputs&lt;/strong&gt; will be explored much, much later in the series.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Inputs are evaluated using the following syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;${{ job.inputs.INPUT NAME }}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Job inputs contain other sub-keywords, with the use of which, further input configuration is possible.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;default&lt;/code&gt;: The default value provided to each input. All inputs must have a default value.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;options&lt;/code&gt;: Optional. Provides a list of allowed options for the input.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;description&lt;/code&gt;: Optional. Provides a description for the input.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;type&lt;/code&gt;: Optional. Specifies what kind of values it can take — &lt;code&gt;number&lt;/code&gt;, &lt;code&gt;string&lt;/code&gt;, &lt;code&gt;boolean&lt;/code&gt;, &lt;code&gt;array&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;regex&lt;/code&gt;: Optional. Specifies the regular expression that a input’s value must match. Mostly used for *&lt;a href="https://semver.org/" rel="noopener noreferrer"&gt;semantic versioning&lt;/a&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;deploy_to_aws&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;inputs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# first input&lt;/span&gt;
    &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;default&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;aws&lt;/span&gt;
      &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;string&lt;/span&gt;
      &lt;span class="c1"&gt;# 👉 the default value used must be included inside options!&lt;/span&gt;
      &lt;span class="na"&gt;options&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;aws"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;azure"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gcp"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;vercel"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Target Cloud Provider&lt;/span&gt;

    &lt;span class="c1"&gt;# second input&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;default&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;production&lt;/span&gt;
      &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;string&lt;/span&gt;
      &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Target Environment&lt;/span&gt;

    &lt;span class="c1"&gt;# third input&lt;/span&gt;
    &lt;span class="na"&gt;deployed_containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;default&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
      &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;number&lt;/span&gt;
      &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Number of containers deployed by this job&lt;/span&gt;

    &lt;span class="c1"&gt;# fourth input&lt;/span&gt;
    &lt;span class="na"&gt;tag&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;default&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1.0.0&lt;/span&gt;
      &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;string&lt;/span&gt;
      &lt;span class="na"&gt;regex&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;^v\d+\.\d+(\.\d)?$'&lt;/span&gt;
      &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Semantic Versioning&lt;/span&gt;

  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# small note: this is called pipelining — running multiple commands&lt;/span&gt;
    &lt;span class="c1"&gt;# at once&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
        &lt;span class="s"&gt;echo "Deploying to ${{ job.inputs.target }}"&lt;/span&gt;
        &lt;span class="s"&gt;echo "Environment: ${{ job.inputs.environment }}"&lt;/span&gt;
        &lt;span class="s"&gt;echo "Containers deployed: ${{ job.inputs.deployed_containers }}"&lt;/span&gt;
        &lt;span class="s"&gt;echo "Tag: ${{ job.inputs.tag }}"&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;$CI_COMMIT_BRANCH&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;==&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;$CI_DEFAULT_BRANCH'&lt;/span&gt;
      &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;manual&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output of the above job is described below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Deploying to aws"&lt;/span&gt; &lt;span class="c"&gt;# collapsed multi-line command&lt;/span&gt;
Deploying to aws
Environment: production
Containers deployed: 1
Tag: v1.0.0
Cleaning up project directory and file based variables
00:01
Job succeeded
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;A note before we end things here for this post: Try to decipher the workflow, the behaviour and output of each code block’s examples. It helps in learning pipeline behaviours much quicker and outlining areas prone to errors!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>automation</category>
      <category>cicd</category>
      <category>devops</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>The GitLab CI Manual: The Textbook You’ve Always Needed — #1 Introduction</title>
      <dc:creator>Arnav</dc:creator>
      <pubDate>Mon, 26 Oct 2026 10:19:01 +0000</pubDate>
      <link>https://dev.to/arnavgit923/the-gitlab-ci-manual-the-textbook-youve-always-needed-1-introduction-4bnf</link>
      <guid>https://dev.to/arnavgit923/the-gitlab-ci-manual-the-textbook-youve-always-needed-1-introduction-4bnf</guid>
      <description>&lt;h2&gt;
  
  
  Preface
&lt;/h2&gt;

&lt;p&gt;Before diving in to the basics, this post would like to implore the reader to look up definitions of all the technical jargon that will naturally follow in the series. You cannot build a technical understanding of the structures involved unless you’re proficient in the language it speaks.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: All technical jargon will be marked with an asterisk (*), making it easier to identify them for lookups.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is the first in a 5-part series that aims to act as a manual to developers who are either starting out learning GitLab CI/CD or more senior devs looking for a handbook.&lt;/p&gt;

&lt;h2&gt;
  
  
  First order of business — What are CI/CD pipelines, and why GitLab?
&lt;/h2&gt;

&lt;p&gt;In order to comprehend the concept that is automation and pipelines, we need to trace the history of why these things came into place, the technologies that came after and how refined they became over time.&lt;/p&gt;

&lt;p&gt;To give a brief introduction, before pipelines, developers had to manually set up everything — from installing dependencies required by apps to setting up infrastructure for their projects to run.&lt;/p&gt;

&lt;p&gt;After the advent of scripting, it became a lot easier to automate manual tasks with the run of a single &lt;code&gt;.sh&lt;/code&gt; file. But scripting brought up its own sets of problems, one of them being deployment.&lt;/p&gt;

&lt;p&gt;Deployment was still done manually, because scripting produced many errors such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Silent Failures&lt;/strong&gt; — Scripts return a success exit code (0), but they do not stop executing after a command fails, unless explicitly written otherwise using set -e.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unset Variable Issues&lt;/strong&gt; — Scripts depend on the host environment. If a variable is mis-spelt or missing on the production server, then the entire script breaks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unverified Releases&lt;/strong&gt; — Running scripts without automated health checks can leave services in a broken state without anyone knowing the root cause.
And thus, to fix such problems, &lt;strong&gt;pipelines&lt;/strong&gt; were born.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  CI/CD Pipelines — Demystified
&lt;/h2&gt;

&lt;p&gt;CI/CD pipelines are Continuous Integration/Continuous Delivery tools that aid in automating 90% of the work that you would have otherwise done manually, such as deployment, setting up infrastructure on a server, etc.&lt;/p&gt;

&lt;p&gt;Any changes you make in your code base or structure immediately get integrated and tested by the pipeline — the &lt;strong&gt;Continuous Integration&lt;/strong&gt; part — and then deployed to a cloud platform of your choice, which falls under the &lt;strong&gt;Continuous Delivery&lt;/strong&gt; section (AWS, Microsoft Azure, Google Cloud, etc.).&lt;/p&gt;

&lt;p&gt;There are many CI tools that came about after the advent of pipelining. A few notable ones are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Actions&lt;/strong&gt;, as provided by &lt;strong&gt;GitHub&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitLab CI&lt;/strong&gt;, as provided by &lt;strong&gt;GitLab&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Jenkins&lt;/strong&gt;, which is an *open-source downloadable automation tool that is hosted on a server locally, such as an &lt;code&gt;EC2 Instance&lt;/code&gt; or a &lt;code&gt;Kubernetes&lt;/code&gt; cluster.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CircleCI&lt;/strong&gt;, which is a *SaaS platform that integrates across all repositories, such as GitHub, GitLab, BitBucket, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is no “proper” or “best” pipeline, since the primary work that each tool does is automation, while offering different sets of features, such as GitLab CI offering native *Terraform integration, whereas GitHub Actions — being relatively new — does not, requiring third-party support. But that is about the degree to which the distinction between each pipeline goes.&lt;/p&gt;

&lt;p&gt;Of course, the choice varies from company-to-company. The employee must, then, learn to be flexible to suit the company’s requirements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why GitLab CI? Why not other CI tools?
&lt;/h2&gt;

&lt;p&gt;Herein lies the “paradox of choice”. There are several repo-hosting platforms available that offer CI/CD capabilities, so choosing each depends on the pros and cons of each platform, along with the needs of the individual/team.&lt;/p&gt;

&lt;p&gt;A table is then best suited to provide a more direct comparison between each platform, their benefits, and the costs they offer.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Platform / Tool&lt;/th&gt;
&lt;th&gt;Primary Focus&lt;/th&gt;
&lt;th&gt;Core Advantage&lt;/th&gt;
&lt;th&gt;Best Suited For&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;GitLab&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;All-in-one DevOps lifecycle&lt;/td&gt;
&lt;td&gt;Native *Terraform integration out-of-the-box&lt;/td&gt;
&lt;td&gt;Production-standard DevOps engineering teams&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;GitHub&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Source control &amp;amp; collaboration&lt;/td&gt;
&lt;td&gt;Massive marketplace ecosystem of Actions&lt;/td&gt;
&lt;td&gt;General development &amp;amp; open-source projects&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Bitbucket&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Atlassian ecosystem synergy&lt;/td&gt;
&lt;td&gt;Built-in Jira and Confluence link tracking&lt;/td&gt;
&lt;td&gt;Enterprise environments already deep in Jira&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;JFrog Artifactory&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Universal binary repository&lt;/td&gt;
&lt;td&gt;Specialized artifact management &amp;amp; storage&lt;/td&gt;
&lt;td&gt;High-scale dependency management &amp;amp; security&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;While GitHub and BitBucket offer more features in general development — with JFrog Artifactory offering solely binary storage — GitLab stands out as the best production-standard for a DevOps team when it comes to offering a pure DevOps-related repository hosting platform.&lt;/p&gt;

&lt;p&gt;And thus, we shall begin by navigating through GitLab and its main attraction point for many developers — &lt;strong&gt;CI/CD capabilities&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Any corrections in this post will be much appreciated in the comments!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>automation</category>
      <category>cicd</category>
      <category>devops</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
