{"id":11566,"date":"2025-11-25T16:45:59","date_gmt":"2025-11-25T11:15:59","guid":{"rendered":"https:\/\/www.youstable.com\/blog\/?p=11566"},"modified":"2025-11-27T11:39:40","modified_gmt":"2025-11-27T06:09:40","slug":"configure-ci-cd-on-linux","status":"publish","type":"post","link":"https:\/\/www.youstable.com\/blog\/configure-ci-cd-on-linux","title":{"rendered":"Configure CI\/CD on Linux Server for Reliable Deployments"},"content":{"rendered":"\n<p>CI\/CD (Continuous Integration\/Continuous Deployment) is a set of modern software development practices that allow you to automate the process of building, testing, and deploying code to production. By learning how to configure CI\/CD, you can ensure that every code change is automatically tested, built, and deployed, improving the quality and speed of software delivery.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Configuring CI\/CD on a Linux server enables you to streamline your development workflow and deliver new features and fixes to users faster and more reliably.<\/p>\n\n\n\n<p>In this guide, we will walk you through setting up a basic CI\/CD pipeline using&nbsp;<strong>Jenkins<\/strong>, a popular open-source automation server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"prerequisites\"><strong>Prerequisites<\/strong><\/h2>\n\n\n\n<p>Before configuring CI\/CD pipeline on your Linux server, ensure the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Linux Server<\/strong>: A Linux-based server (Ubuntu, CentOS, Debian, etc.) with root or sudo access.<\/li>\n\n\n\n<li><strong>Jenkins Installation<\/strong>: Jenkins will be used for automating the CI\/CD pipeline.<\/li>\n\n\n\n<li><strong>Git Repository<\/strong>: You should have a project in a Git repository (e.g., GitHub, GitLab, Bitbucket).<\/li>\n\n\n\n<li><strong>Java<\/strong>: Jenkins requires Java to run, so Java needs to be installed on your server.<\/li>\n<\/ul>\n\n\n\n<p>Once you have these prerequisites, you can begin setting up your CI\/CD pipeline.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"configure-ci-cd-on-linux-server\"><strong>Configure CI\/CD on Linux Server<\/strong><\/h2>\n\n\n\n<p>To configure CI\/CD on a Linux server, you need to set up tools that automate code integration, testing, and deployment. This streamlines development workflows, ensures faster delivery, and helps maintain high-quality software through continuous monitoring and automation.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-1-install-jenkins\"><strong>Step 1: Install Jenkins<\/strong><\/h3>\n\n\n\n<p>Jenkins will be the core tool in our&nbsp;<a href=\"https:\/\/web.archive.org\/web\/20250809092815\/https:\/\/www.youstable.com\/blog\/install-ci-cd-on-linux\/\">CI\/CD pipeline<\/a>, automating the build, test, and deployment processes.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"install-java\"><strong>Install Java<\/strong><\/h4>\n\n\n\n<p>Jenkins requires Java to run. You can install OpenJDK (Java Development Kit) on your Linux server.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>On Ubuntu\/Debian:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo apt update\nsudo apt install openjdk-11-jdk\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>On CentOS\/RHEL:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo yum install java-11-openjdk-devel\n<\/pre><\/div>\n\n\n<p>Check the installed Java version:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\njava -version\n<\/pre><\/div>\n\n\n<h4 class=\"wp-block-heading\" id=\"install-jenkins\"><strong>Install Jenkins<\/strong><\/h4>\n\n\n\n<p>To install Jenkins, first, add the official Jenkins repository and key.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>On Ubuntu\/Debian:<\/strong><\/li>\n<\/ul>\n\n\n\n<p>Add the Jenkins repository and GPG key:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nwget -q -O - https:\/\/pkg.jenkins.io\/ci.ubuntu.com\/jenkins.io.key | sudo apt-key add -\necho &quot;deb http:\/\/pkg.jenkins.io\/debian\/ stable main&quot; | sudo tee -a \/etc\/apt\/sources.list.d\/jenkins.list\n<\/pre><\/div>\n\n\n<p>Install Jenkins:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo apt update sudo apt install jenkins\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>On CentOS\/RHEL:<\/strong><\/li>\n<\/ul>\n\n\n\n<p>Add the Jenkins repository:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo wget -O \/etc\/yum.repos.d\/jenkins.repo https:\/\/pkg.jenkins.io\/redhat\/jenkins.repo\n<\/pre><\/div>\n\n\n<p>Import the GPG key:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo rpm --import https:\/\/pkg.jenkins.io\/redhat\/jenkins.io.key\n<\/pre><\/div>\n\n\n<p>Install Jenkins:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo yum install jenkins\n<\/pre><\/div>\n\n\n<h4 class=\"wp-block-heading\" id=\"start-jenkins\"><strong>Start Jenkins<\/strong><\/h4>\n\n\n\n<p>Once Jenkins is installed, start and enable Jenkins to start at boot.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>On Ubuntu\/Debian:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo systemctl start jenkins\nsudo systemctl enable jenkins\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>On CentOS\/RHEL:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo systemctl start jenkins\nsudo systemctl enable jenkins\n<\/pre><\/div>\n\n\n<h4 class=\"wp-block-heading\" id=\"open-jenkins-in-the-browser\"><strong>Open Jenkins in the Browser<\/strong><\/h4>\n\n\n\n<p>By default, Jenkins runs on port 8080. You can access it by opening your browser and navigating to:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nhttp:\/\/your-server-ip:8080\n<\/pre><\/div>\n\n\n<p>You\u2019ll be asked to unlock Jenkins by providing a password. To get this password, run:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo cat \/var\/lib\/jenkins\/secrets\/initialAdminPassword\n<\/pre><\/div>\n\n\n<p>Copy the password and paste it into the web interface to complete the setup.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-2-install-necessary-jenkins-plugins\"><strong>Step 2: Install Necessary Jenkins Plugins<\/strong><\/h3>\n\n\n\n<p>Jenkins comes with a basic set of plugins, but to enable integration with Git, GitHub, and various deployment tools, you\u2019ll need to install additional plugins.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"install-git-plugin\"><strong>Install Git Plugin<\/strong>:<\/h4>\n\n\n\n<p>The Git plugin allows Jenkins to connect to a Git repository.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to\u00a0<strong>Manage Jenkins<\/strong>\u00a0\u2192\u00a0<strong>Manage Plugins<\/strong>.<\/li>\n\n\n\n<li>Select the\u00a0<strong>Available<\/strong>\u00a0tab, search for \u201cGit plugin,\u201d and install it.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"install-pipeline-plugin\"><strong>Install Pipeline Plugin<\/strong>:<\/h4>\n\n\n\n<p>This plugin enables you to create CI\/CD pipelines as code.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to\u00a0<strong>Manage Jenkins<\/strong>\u00a0\u2192\u00a0<strong>Manage Plugins<\/strong>.<\/li>\n\n\n\n<li>Select the\u00a0<strong>Available<\/strong>\u00a0tab, search for \u201cPipeline,\u201d and install it.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"install-ssh-and-deployment-plugins\"><strong>Install SSH and Deployment Plugins<\/strong>:<\/h4>\n\n\n\n<p>For deployment tasks, you can install plugins such as&nbsp;<strong>SSH Agent Plugin<\/strong>&nbsp;(for&nbsp;<a href=\"https:\/\/web.archive.org\/web\/20250809092815\/https:\/\/www.youstable.com\/blog\/configure-ssh-on-linux\/\">SSH key management<\/a>) and&nbsp;<strong>Publish Over SSH<\/strong>&nbsp;(for deployment).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-3-configure-git-repository-integration\"><strong>Step 3: Configure Git Repository Integration<\/strong><\/h3>\n\n\n\n<p>Jenkins needs to&nbsp;<a href=\"https:\/\/web.archive.org\/web\/20250809092815\/https:\/\/www.youstable.com\/blog\/configure-git-on-linux\/\">access the Git<\/a>&nbsp;repository to pull the code and trigger builds.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"add-your-git-repository\"><strong>Add Your Git Repository<\/strong>:<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to\u00a0<strong>Manage Jenkins<\/strong>\u00a0\u2192\u00a0<strong>Configure System<\/strong>.<\/li>\n\n\n\n<li>Under\u00a0<strong>Git<\/strong>, add the path to your Git executable.<\/li>\n\n\n\n<li>Configure\u00a0<strong>GitHub Integration<\/strong>\u00a0(if you\u2019re using GitHub) under\u00a0<strong>GitHub Servers<\/strong>\u00a0by adding your credentials (OAuth token, username\/password).<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"create-a-jenkins-job\"><strong>Create a Jenkins Job<\/strong>:<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to the Jenkins dashboard, click\u00a0<strong>New Item<\/strong>, and create a\u00a0<strong>Freestyle Project<\/strong>.<\/li>\n\n\n\n<li>Under the\u00a0<strong>Source Code Management<\/strong>\u00a0section, select\u00a0<strong>Git<\/strong>\u00a0and provide the repository URL and credentials (if necessary).<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-4-create-a-pipeline-for-ci-cd\"><strong>Step 4: Create a Pipeline for CI\/CD<\/strong><\/h3>\n\n\n\n<p><a href=\"https:\/\/web.archive.org\/web\/20250809092815\/https:\/\/www.jenkins.io\/doc\/\" target=\"_blank\" rel=\"noreferrer noopener\">Jenkins<\/a>&nbsp;Pipelines allow you to define your CI\/CD pipeline as code using a&nbsp;<code>Jenkinsfile<\/code>. This file contains instructions for building, testing, and deploying your code.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"create-a-jenkinsfile-in-your-projects-root-directory\"><strong>Create a Jenkinsfile in Your Project\u2019s Root Directory<\/strong><\/h4>\n\n\n\n<p>A simple example of&nbsp;<code>Jenkinsfile<\/code>&nbsp;for a Node.js project might look like this:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\">pipeline {\n    agent any\n\n    stages {\n        stage('Checkout') {\n            steps {\n                git 'https:\/\/github.com\/your-username\/your-repo.git'\n            }\n        }\n        stage('Build') {\n            steps {\n                script {\n                    sh 'npm install'\n                }\n            }\n        }\n        stage('Test') {\n            steps {\n                script {\n                    sh 'npm test'\n                }\n            }\n        }\n        stage('Deploy') {\n            steps {\n                sshPublisher(\n                    publishers: [\n                        sshPublisherDesc(\n                            configName: 'your-server',\n                            transfers: [\n                                sshTransfer(\n                                    sourceFiles: '**\/*.tar.gz',\n                                    remoteDirectory: '\/path\/to\/remote\/dir',\n                                    removePrefix: 'dist',\n                                    execCommand: 'tar -xzvf \/path\/to\/remote\/dir\/*.tar.gz'\n                                )\n                            ]\n                        )\n                    ]\n                )\n            }\n        }\n    }\n}\n<\/pre>\n\n\n\n<p>In this pipeline:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Checkout<\/strong>: Pulls the latest code from Git.<\/li>\n\n\n\n<li><strong>Build<\/strong>: Runs\u00a0<code>npm install<\/code>\u00a0to install dependencies.<\/li>\n\n\n\n<li><strong>Test<\/strong>: Runs\u00a0<code>npm test<\/code>\u00a0to execute unit tests.<\/li>\n\n\n\n<li><strong>Deploy<\/strong>: Uses SSH to deploy the build to a remote server.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"create-the-pipeline-in-jenkins\"><strong>Create the Pipeline in Jenkins<\/strong>:<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to\u00a0<strong>New Item<\/strong>\u00a0and select\u00a0<strong>Pipeline<\/strong>.<\/li>\n\n\n\n<li>Under the\u00a0<strong>Pipeline<\/strong>\u00a0section, set the\u00a0<strong>Definition<\/strong>\u00a0to \u201cPipeline script from SCM.\u201d<\/li>\n\n\n\n<li>Choose\u00a0<strong>Git<\/strong>\u00a0as the SCM, provide the repository URL, and point Jenkins to the\u00a0<code>Jenkinsfile<\/code>\u00a0in your repo.<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-5-trigger-builds\"><strong>Step 5: Trigger Builds<\/strong><\/h3>\n\n\n\n<p>Jenkins can trigger builds automatically based on various events, such as code pushes or pull requests.<\/p>\n\n\n\n<p><strong>Trigger Build on Code Push<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Under\u00a0<strong>Build Triggers<\/strong>, enable\u00a0<strong>GitHub hook trigger for GITScm polling<\/strong>\u00a0(if using GitHub).<\/li>\n\n\n\n<li>Alternatively, use\u00a0<strong>Poll SCM<\/strong>\u00a0to configure periodic polling for changes.<\/li>\n<\/ul>\n\n\n\n<p><strong>Manual Trigger<\/strong>:<\/p>\n\n\n\n<p>You can also trigger builds manually by going to the Jenkins dashboard and clicking on&nbsp;<strong>Build Now<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-6-monitor-and-maintain-the-pipeline\"><strong>Step 6: Monitor and Maintain the Pipeline<\/strong><\/h3>\n\n\n\n<p>Jenkins provides a detailed view of each pipeline run, including logs, build results, and test outputs.<\/p>\n\n\n\n<p><strong>View Build Logs<\/strong>: From the Jenkins job page, click on a build to view its logs and see where any errors occurred.<\/p>\n\n\n\n<p><strong>Configure Notifications<\/strong>: Jenkins can send email notifications or integrate with services like Slack to notify the team about build statuses.<\/p>\n\n\n\n<p><strong>Automate Deployments<\/strong>: Jenkins can be configured to automatically deploy the application to various environments (e.g., staging, production) once the build and tests pass.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>In this guide, we have walked through how to configure CI\/CD on a Linux server using Jenkins, from installation and integration with Git to creating a Jenkins pipeline for continuous integration and deployment. By automating your software build, test, and deployment processes, you improve the efficiency of your development workflow and ensure faster, more reliable software delivery.<\/p>\n\n\n\n<p>With Jenkins set up, you now have a powerful CI\/CD pipeline running on your Linux server, capable of managing the complete lifecycle of your code from development to production. By continuously integrating and deploying changes, your software will be more stable and secure, allowing your team to focus on delivering new features instead of manually managing deployments.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CI\/CD (Continuous Integration\/Continuous Deployment) is a set of modern software development practices that allow you to automate the process of [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":11567,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[350],"tags":[],"class_list":["post-11566","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-knowledgebase"],"acf":[],"featured_image_src":"https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2025\/11\/Configure-CICD-on-Linux-Server-for-Reliable-Deployments.png","author_info":{"display_name":"Prahlad Prajapati","author_link":"https:\/\/www.youstable.com\/blog\/author\/prahladblog"},"_links":{"self":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts\/11566","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/comments?post=11566"}],"version-history":[{"count":2,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts\/11566\/revisions"}],"predecessor-version":[{"id":15769,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts\/11566\/revisions\/15769"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/media\/11567"}],"wp:attachment":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/media?parent=11566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/categories?post=11566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/tags?post=11566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}