<?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: Amish</title>
    <description>The latest articles on DEV Community by Amish (@outofindex).</description>
    <link>https://dev.to/outofindex</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1263848%2F2aeb2b3a-9709-4960-b0d3-98637ed9a3ef.jpeg</url>
      <title>DEV Community: Amish</title>
      <link>https://dev.to/outofindex</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/outofindex"/>
    <language>en</language>
    <item>
      <title>Efficient CI/CD with Shared Configurations in GitLab</title>
      <dc:creator>Amish</dc:creator>
      <pubDate>Tue, 23 Jan 2024 08:44:05 +0000</pubDate>
      <link>https://dev.to/outofindex/efficient-cicd-with-shared-configurations-in-gitlab-4k87</link>
      <guid>https://dev.to/outofindex/efficient-cicd-with-shared-configurations-in-gitlab-4k87</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyhrg943x1ayz1tqe6s9j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyhrg943x1ayz1tqe6s9j.png" alt="header" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
Original post, first published on &lt;a href="https://outofindex.medium.com/efficient-ci-cd-with-shared-configurations-in-gitlab-0b0e28712892"&gt;medium account&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In the realm of Continuous Integration and Continuous Deployment (CI/CD), maintaining consistency across multiple projects can be challenging. GitLab CI offers a powerful feature called “Shared CI Configurations”, enabling teams to streamline their CI/CD workflows and foster code reuse.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnjvlssssg3ladij7u71a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnjvlssssg3ladij7u71a.png" alt="gitlab logo" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this blog post, we’ll explore how to leverage shared CI configurations to enhance efficiency and maintain a standardized approach across projects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Understanding Shared CI Configurations:&lt;/strong&gt;&lt;br&gt;
GitLab’s Shared CI Configurations allow teams to define CI/CD configurations in a separate repository and then include these configurations in other projects. This approach promotes code reuse, reduces duplication, and ensures a uniform CI/CD setup across different repositories.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use Case:&lt;/strong&gt;&lt;br&gt;
Reusable CI Configurations for Mini-Apps&lt;br&gt;
Consider a scenario where a development team is managing several mini-apps or modules within a larger project. Each mini-app shares common CI/CD steps, such as building, testing, and deploying. Instead of duplicating these configurations in each mini-app, the team can centralize the CI/CD setup in a shared configuration repository.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Getting Started:&lt;/strong&gt;&lt;br&gt;
Create a Shared CI Configurations Repository: Start by creating a new repository specifically for storing shared CI configurations. This repository will house the &lt;code&gt;.gitlab-ci.yml&lt;/code&gt; file and any scripts or configurations that multiple projects can reuse.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Define Shared CI Configurations:&lt;/strong&gt;&lt;br&gt;
Craft the CI/CD configurations in the shared repository according to the needs of your projects. Consider defining stages, jobs, and environment variables that are commonly used across projects.&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="c1"&gt;# .gitlab-ci.yml in Shared CI Configurations Repository&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;test&lt;/span&gt;

&lt;span class="na"&gt;build_job&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 the application..."&lt;/span&gt;

&lt;span class="na"&gt;test_job&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 "Running tests..."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Include Shared Configurations in Projects:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In each mini-app or module repository, include the shared configurations using the &lt;code&gt;include&lt;/code&gt; directive in the project's &lt;code&gt;.gitlab-ci.yml&lt;/code&gt; file.&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="c1"&gt;# .gitlab-ci.yml in Mini-App Repository&lt;/span&gt;

&lt;span class="na"&gt;include&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;project&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;your-group/shared-ci-configurations'&lt;/span&gt;
    &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/path/to/.gitlab-ci.yml'&lt;/span&gt;
    &lt;span class="na"&gt;ref&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;main&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Advantages of Shared CI Configurations:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consistency Across Projects:&lt;/strong&gt; Shared CI configurations ensure that all mini-apps within the project follow the same CI/CD process. This consistency is crucial for a unified development and deployment experience.&lt;br&gt;
&lt;strong&gt;Ease of Maintenance:&lt;/strong&gt;&lt;br&gt;
Updates or improvements to the CI/CD pipeline can be made in a single location — the shared configurations repository — making maintenance more straightforward.&lt;br&gt;
&lt;strong&gt;Code Reusability:&lt;/strong&gt;&lt;br&gt;
Reusing CI configurations reduces redundancy and minimizes the effort needed to set up CI/CD for each mini-app. This is especially beneficial in projects with many modules.&lt;br&gt;
&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br&gt;
Shared CI Configurations in GitLab CI offer a powerful solution for maintaining a cohesive CI/CD strategy across multiple projects. By centralizing configurations, teams can enhance consistency, reduce duplication, and optimize their development workflows. As teams continue to embrace CI/CD best practices, the use of shared configurations becomes a valuable asset in their toolset.&lt;/p&gt;

</description>
      <category>cicd</category>
      <category>gitlab</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
