{"id":138373,"date":"2020-12-21T16:00:52","date_gmt":"2020-12-21T13:00:52","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/getting-started-with-gitlabs-continuous-integration-deployment-pipelines-ci-cd-cloudsavvy-it\/"},"modified":"2020-12-21T16:00:52","modified_gmt":"2020-12-21T13:00:52","slug":"getting-started-with-gitlabs-continuous-integration-deployment-pipelines-ci-cd-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/getting-started-with-gitlabs-continuous-integration-deployment-pipelines-ci-cd-cloudsavvy-it\/","title":{"rendered":"#Getting Started With GitLab\u2019s Continuous Integration &#038; Deployment Pipelines (CI\/CD) \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a3894b3be673\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a3894b3be673\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/getting-started-with-gitlabs-continuous-integration-deployment-pipelines-ci-cd-cloudsavvy-it\/#Setting_Up_a_Build_Server_GitLab_Runner\" >Setting Up a Build Server (GitLab Runner)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/getting-started-with-gitlabs-continuous-integration-deployment-pipelines-ci-cd-cloudsavvy-it\/#Setting_Up_CICD_For_Your_Project\" >Setting Up CI\/CD For Your Project<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#Getting Started With GitLab\u2019s Continuous Integration &amp; Deployment Pipelines (CI\/CD) \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2242\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/a9dd1f717cc7b5354632598922bcc2f0\/p\/uploads\/2019\/10\/73a5aadf.png\" alt=\"\" width=\"700\" height=\"299\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Continuous Integration and Deployment, or CI\/CD, is the process of streamlining and accelerating development by automatically building and testing every commit to your project. GitLab integrates CI\/CD into their <code>git<\/code>\u00a0solution extremely well, and we\u2019ll show how to set it up and work with it.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Setting_Up_a_Build_Server_GitLab_Runner\"><\/span>Setting Up a Build Server (GitLab Runner)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Often, compiling code can be an extremely intensive operation. Not all languages have this issue, but some, like C++, can take over half an hour to complete a complicated build. Chromium, for example, can take over an hour even on 12-core systems, as shown here in this graph from <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/game\/\" data-internallinksmanager029f6b8e52c=\"7\" title=\"Game\" target=\"_blank\" rel=\"noopener\">Game<\/a>rsNexus.<\/p>\n<figure id=\"attachment_8631\" style=\"width: 700px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8631 size-full\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/b1349136d0b45f388a229ceba4067e94\/p\/uploads\/2020\/12\/21818618.png\" alt=\"\" width=\"700\" height=\"277\" data-crediturl=\"https:\/\/www.gamersnexus.net\/guides\/3577-cpu-test-methodology-unveil-for-2020-compile-gaming-more\" data-credittext=\"GamersNexus\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><figcaption class=\"wp-caption-text\"><span class=\"imagecredit\"><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.gamersnexus.net\/guides\/3577-cpu-test-methodology-unveil-for-2020-compile-gaming-more\">GamersNexus<\/a><\/span><\/figcaption><\/figure>\n<p>Time is money, so many companies will opt to have dedicated build servers, often a swarm of servers, and run their CI\/CD pipelines on powerful hardware.<\/p>\n<p>If you\u2019re not self hosting, and are instead using GitLab\u2019s online SaaS solution (gitlab.com), then you\u2019ll need to pay for CI\/CD minutes. The free tier includes 400 CI\/CD minutes, which should be enough for simple projects, especially languages like JS where all that may be necessary is a basic <code>npm build<\/code>. The higher tiers, which charge per user, offer much more build time. You can view the up-to-date totals <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/about.gitlab.com\/pricing\/\">from GitLab\u2019s pricing information page<\/a>.<\/p>\n<p>In our case, we\u2019re self hosting, so we\u2019ll need to set up a GitLab Runner, which installs on a server and configures it as a build agent. This is available as a binary as well as a Kubernetes deployment, which may be ideal for auto-scaling multi-server deployments.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8633\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/9a28c23d59725255227911efd68e1124\/p\/uploads\/2020\/12\/c9916f8d.png\" alt=\"\" width=\"700\" height=\"498\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Fortunately the install process is simple. You\u2019ll need to find which binary you\u2019ll need for your host, and <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">download<\/a> it. For Debian based systems like Ubuntu, that would be the <code>deb<\/code>\u00a0package:<\/p>\n<pre><!--StartFragment --><\/pre>\n<pre>curl -LJO \"https:\/\/gitlab-runner-downloads.s3.amazonaws.com\/latest\/deb\/gitlab-runner_amd64.deb\"<!--EndFragment --><\/pre>\n<p>And install it with <code>dpkg<\/code>:<\/p>\n<pre>sudo dpkg -i gitlab-runner_amd64.deb<!--EndFragment --><\/pre>\n<p>Next, you\u2019ll need to <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/docs.gitlab.com\/runner\/register\/\">configure it with the URL <\/a>and token found in\u00a0\/admin\/runners.<\/p>\n<pre>sudo gitlab-runner register<\/pre>\n<p>You\u2019ll be asked to specify what executor this runner should use. In most cases, you can just use \u201cdocker,\u201d with a default image like ubuntu.<\/p>\n<p>Once configured, you can start the runner:<\/p>\n<pre>sudo gitlab-runner register<\/pre>\n<p>Then you should see it in the list.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8641\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/96ece7989c055ac8307724bc55af94d5\/p\/uploads\/2020\/12\/c789bc4b.png\" alt=\"\" width=\"700\" height=\"233\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>In our case, there was a weird bug where the runner would not start because the <code>\/var\/lib\/gitlab-runner<\/code>\u00a0folder was not present. Manually creating it solved the issue im<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/social-mediaa\/\" data-internallinksmanager029f6b8e52c=\"1\" title=\"Social Media\" target=\"_blank\" rel=\"noopener\">media<\/a>tely:<\/p>\n<pre>sudo mkdir \/var\/lib\/gitlab-runner<\/pre>\n<p>You will need to open the settings for the runner, and set proper tags for it that will get picked up by matching gitlab-ci.yml config files. If you\u2019d instead not bother with tags, you can check this box here to pick up untagged jobs:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8642\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/349c6a57236ec4269d639e683e558ea2\/p\/uploads\/2020\/12\/44f3da7f.png\" alt=\"\" width=\"700\" height=\"287\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Next, you\u2019ll need to configure your projects to use this runner.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Setting_Up_CICD_For_Your_Project\"><\/span>Setting Up CI\/CD For Your Project<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Configuring GitLab CI is done with a file at the root of your project, called <code>.gitlab-ci.yml<\/code>. This is automatically used to run.<\/p>\n<p>Of course, the exact configuration of this will depend highly on you and your needs. A good place to start would be looking up how others have done it for your language and runtime.<\/p>\n<p>For example, a simple .NET build can be run using a config like the following:<\/p>\n<pre>image : microsoft\/dotnet:latest&#13;\n&#13;\nstages:&#13;\n  - build&#13;\n&#13;\nbefore_script:&#13;\n  - 'dotnet restore'&#13;\n&#13;\nbuild:&#13;\n  stage: build&#13;\n  script:&#13;\n    - 'dotnet build'<\/pre>\n<p>First, we need to set the Docker image that GitLab will use to build your application. This is important because otherwise the environment won\u2019t have the .NET runtime. Before anything, it runs <code>dotnet restore<\/code>, then runs <code>dotnet build<\/code>\u00a0to actually build the application.<\/p>\n<p>To learn more about the structure of this file, you <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/docs.gitlab.com\/ee\/ci\/yaml\/\">can consult GitLab\u2019s documentation<\/a>.<\/p>\n<p>Once committed to your repo, that commit will trigger the first pipeline. You can view pipeline results under CI\/CD &gt; Pipelines, where you\u2019ll see each run alongside its status.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8662\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/391124b69e5f271baa3dd2aac55b99ec\/p\/uploads\/2020\/12\/9c3e1585.png\" alt=\"\" width=\"700\" height=\"259\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>If you click the details, you can debug what went wrong with failed run, as it keeps a log of the console.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8663\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/dd81f618fc0e06ff7bf6583d6c945425\/p\/uploads\/2020\/12\/05193c61.png\" alt=\"\" width=\"700\" height=\"327\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/>\n<\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/8629\/getting-started-with-gitlabs-continuous-integration-deployment-pipelines-ci-cd\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#Getting Started With GitLab\u2019s Continuous Integration &amp; Deployment Pipelines (CI\/CD) \u2013 CloudSavvy IT&#8221; Continuous Integration and Deployment, or CI\/CD, is the process of streamlining and accelerating development by automatically building and testing every commit to your project. GitLab integrates CI\/CD into their git\u00a0solution extremely well, and we\u2019ll show how to set it up and work&#8230;<\/p>\n","protected":false},"author":1,"featured_media":138374,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/10\/73a5aadf.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-138373","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/138373","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=138373"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/138373\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/138374"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=138373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=138373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=138373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}