<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Alparslan Uysal on Medium]]></title>
        <description><![CDATA[Stories by Alparslan Uysal on Medium]]></description>
        <link>https://medium.com/@alparslanuysal?source=rss-37229d01f38------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*AjhwDiy_oBZsPUXhlT2R4g.png</url>
            <title>Stories by Alparslan Uysal on Medium</title>
            <link>https://medium.com/@alparslanuysal?source=rss-37229d01f38------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 23:17:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alparslanuysal/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Running Unit Tests in Jenkins]]></title>
            <link>https://faun.pub/running-unit-tests-in-jenkins-2ea96ffe3781?source=rss-37229d01f38------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ea96ffe3781</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[jenkinsfile]]></category>
            <category><![CDATA[unit-test-framework]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[junit]]></category>
            <dc:creator><![CDATA[Alparslan Uysal]]></dc:creator>
            <pubDate>Sat, 22 Mar 2025 15:10:22 GMT</pubDate>
            <atom:updated>2025-03-22T15:10:22.704Z</atom:updated>
            <content:encoded><![CDATA[<h4>Secure Build — DevSecOps Series</h4><p>After developing a new feature or fixing an existing issue in a software product, it is crucial to test whether the requirements have been met before delivering the new product to the customer. Essentially, before the software development processes, we propose a hypothesis. This hypothesis could be something like: “The customer will be presented with the option to select X shipping company at the checkout step,” or “Our product search queries are now 3x faster.” Testing the developments made can be a time-consuming process, and the scope of testing can be very broad. Software tests have multiple levels, such as unit, acceptance, exploratory, and UAT testing. It is very important to operate these test levels to ensure a secure, fast, and low-risk product delivery. Additionally, identifying and addressing potential errors before delivering them to the customer provides significant benefits to the teams. Integrating test processes into automation systems reduces test times and consequently decreases the time required to deliver the developed work. It may not be possible to automate all test levels for every scenario, but in this blog, we will integrate unit tests, which are at the forefront of software test processes, into the deployment pipeline. With this integration, the test report of a development can be viewed in the deployment report, and actions can be taken based on the results.</p><p><strong>What is Unit testing?</strong></p><p>Unit tests are a method of testing to ensure that the smallest units of an application, such as functions, work as designed. The use of unit tests is highly important in the software lifecycle, as certain characteristics provide teams and organizations with benefits for developing and delivering software securely. One of the most crucial characteristics is guiding teams in early error detection. It ensures that a new development works without affecting the existing development, thereby reducing debugging costs within the development cycle. Another key feature is documentation. When developers write unit tests for their code, they indicate how the code should be used. Additionally, unit tests can be run in a short time on every developer’s environment without the need for additional test frameworks. They can also be integrated into the CI pipeline to report whether the developed feature can be built, whether anything is broken, and the operational status of all other functionalities.</p><p>There are test frameworks available for various programming languages. For example, JUnit for Java, NUnit for .NET, pytest for Python, and Jasmine for JavaScript. These frameworks are designed to facilitate writing and running unit tests by providing specific methods and structures.</p><p><strong>Simple Unit Test Example</strong></p><pre>package com.example.hello;<br><br>import org.junit.jupiter.api.Test;<br>import static org.junit.jupiter.api.Assertions.assertEquals;<br>import static org.mockito.Mockito.mock;<br>import static org.mockito.Mockito.when;<br><br>public class GreetingServiceTests {<br> <br> @Test<br>    public void testGetMessage() {<br>        // Create an instance of the service class<br>        GreetingService myService = new GreetingService();<br><br>        // Call the method you want to test<br>        String result = myService.greet();<br><br>        // Assert the result<br>        assertEquals(&quot;Hello, World!&quot;, result);<br>    }<br><br>    @Test<br>    public void testMockedService() {<br>        // Create a mock instance of the service class<br>     GreetingService myServiceMock = mock(GreetingService.class);<br><br>        // Define the behavior of the mock<br>        when(myServiceMock.greet()).thenReturn(&quot;Mocked Hello, World!&quot;);<br><br>        // Call the method you want to test<br>        String result = myServiceMock.greet();<br><br>        // Assert the result<br>        assertEquals(&quot;Mocked Hello, World!&quot;, result);<br>    }<br><br>}</pre><p>After adding the test class, you can run the tests in your local IDE. The tests you write under the test module will be automatically detected, and when you click the Run Test icon in your IDE, the mvn test command will run in the background. You can see the test results in the console output as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*Q4ADGmnr5iCDjq3_iS1vjg.png" /></figure><p><strong>Integrate Unit Test in CI pipeline</strong></p><p>It is crucial for tests to be run and reported by the CI pipeline for central oversight. If a developed feature breaks the functionality of existing developments, this should be observed as early as possible in the local environment. In case something is missed, the CI pipeline should run the tests, fail in case of errors, and provide a report indicating which unit caused the issue. To integrate with the CI pipeline using Jenkins, the JUnit plugin must be active, which is default in most installations. Since our demo project is a Java project, we will use JUnit in this series, but there are various test tools available for node.js, .NET, etc., as mentioned before.</p><p>There are multiple ways to run tests in a CI pipeline. One method is to install the necessary components like Java, Maven, etc., on the build server and run the tests there. Another method, suitable for container projects, is to run the tests within the container while creating the container image. Different methods can be chosen based on requirements, each with its own advantages and disadvantages. Running tests within the container has the advantage of not requiring manual installation of necessary libraries on the build server, making a CI job server-independent and scalable if needed. The advantage of running tests on the build server is that it completely separates the test process from the container image creation step. In this series, we will run tests during the container image creation step and extract the test reports from the container image to report with JUnit. However, you can choose the other method depending on the needs and structure of your project.</p><p>To run tests within the container, we use the mvn test command during the build stage in the Dockerfile and copy the test results to a different directory.</p><pre>#Run maven tests<br>RUN mvn clean test<br># Copy test reports to a separate directory<br>RUN mkdir /workspace/test-reports<br>RUN cp -R target/surefire-reports /workspace/test-reports</pre><p>In the runtime stage, we include the reports we created in the build stage into the final image.</p><pre># Copy test reports from the build stage<br>COPY --from=build /workspace/test-reports /workspace/test-reports</pre><p>The latest version of the Dockerfile that we ran the tests on is as follows.</p><pre>#Build stage<br>FROM maven:3-eclipse-temurin-11 as build<br><br>WORKDIR /workspace/app<br><br>COPY pom.xml .<br>COPY src src<br><br>#Run maven tests<br>RUN mvn clean test<br># Copy test reports to a separate directory<br>RUN mkdir /workspace/test-reports<br>RUN cp -R target/surefire-reports /workspace/test-reports<br><br>RUN mvn clean install<br>RUN mkdir target/extracted<br>RUN java -Djarmode=layertools -jar target/*.jar extract --destination target/extracted<br><br>#Runtime stage<br>FROM eclipse-temurin:11-jdk-alpine<br><br>ARG EXTRACTED=/workspace/app/target/extracted<br><br>COPY --from=build ${EXTRACTED}/dependencies/ ./<br>COPY --from=build ${EXTRACTED}/spring-boot-loader/ ./<br>COPY --from=build ${EXTRACTED}/snapshot-dependencies/ ./<br>COPY --from=build ${EXTRACTED}/application/ ./<br><br># Copy test reports from the build stage<br>COPY --from=build /workspace/test-reports /workspace/test-reports<br><br># Define an entrypoint script<br>COPY entrypoint.sh /entrypoint.sh<br>RUN chmod +x /entrypoint.sh<br><br># Define a default command to run the entrypoint script<br>CMD [&quot;/bin/sh&quot;, &quot;/entrypoint.sh&quot;]</pre><p>We need to configure the Jenkinsfile as follows to facilitate this process. As you can see, after the docker build step, we create a temporary container with docker create, and then use docker cp to extract the JUnit test reports from the temporary container to the host. This is necessary for Jenkins to report the test results.</p><pre>stage(&#39;Build and Test in Docker&#39;) {<br>      steps {<br>          script {<br>              // Build Docker image<br>              sh &quot;docker build -t ${DOCKER_IMAGE} .&quot;<br><br>              // Get tests inside the Docker container<br>              sh &quot;docker create --name temp-container ${DOCKER_IMAGE}:latest&quot;<br>              sh &quot;docker cp temp-container:${CONTAINER_PATH} ${HOST_PATH}&quot;<br>          }<br>      }<br> }</pre><p>In the Publish JUnit Test Results stage, Jenkins uses the JUnit plugin to discover reports based on the **/test-reports/*.xml pattern in the Jenkins workspace and reports them.</p><pre>stage(&#39;Publish JUnit Test Results&#39;) {<br>      steps {<br>          // Publish JUnit test results to Jenkins<br>          junit &quot;**/test-reports/*.xml&quot;<br>      }<br>  }</pre><p>The final version of the Jenkinsfile, which runs the tests and adds the test report to the build output, is as follows:</p><pre>pipeline { <br>    agent any <br><br>    environment {<br>        DOCKER_IMAGE = &#39;springbootdemo&#39;<br>        HOST_PATH = &#39;${WORKSPACE}/test-reports&#39;<br>        CONTAINER_PATH = &#39;/workspace/test-reports/surefire-reports&#39;<br>    }<br>    <br>    stages {<br>        <br>        stage(&#39;Build and Test in Docker&#39;) {<br>            steps {<br>                script {<br>                    // Build Docker image<br>                    sh &quot;docker build -t ${DOCKER_IMAGE} .&quot;<br><br>                    // Get tests inside the Docker container<br>                    sh &quot;docker create --name temp-container ${DOCKER_IMAGE}:latest&quot;<br>                    sh &quot;docker cp temp-container:${CONTAINER_PATH} ${HOST_PATH}&quot;<br>                }<br>            }<br>        }<br><br>        stage(&#39;Publish JUnit Test Results&#39;) {<br>            steps {<br>                // Publish JUnit test results to Jenkins<br>                junit &quot;**/test-reports/*.xml&quot;<br>            }<br>        }<br>    }<br><br>post {<br>        always {<br>            // Cleanup: remove the Docker container<br>            script {<br>                sh &#39;docker container rm -f $(docker container ls -a -q --filter ancestor=${DOCKER_IMAGE})&#39;<br>            }<br>            <br>            // Cleanup: remove the Docker image<br>            script {<br>                sh &quot;docker rmi ${DOCKER_IMAGE}&quot;<br>            }<br><br>            // Cleanup: remove JUnit reports directory<br>            script {<br>                sh &quot;rm -rf ${HOST_PATH}&quot;<br>            }<br>        }<br>    }<br><br>}</pre><p>When you run the Jenkins CI job, you should see a test report like the one below in the build output. This test report shows in detail how many tests have been run and their success status.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bwmpK_0lSfrgK2K-TcEx3A.png" /></figure><p><em>Thank you for reading my blog post! Do you have any additional tips or strategies for CI pipelines? I’m eager to hear your insights. </em><a href="https://twitter.com/uysal_alparslan"><em>Connect with me on Twitter!</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*JPV3iHtxPbNWTS9u.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ea96ffe3781" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/running-unit-tests-in-jenkins-2ea96ffe3781">Running Unit Tests in Jenkins</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configuring Jenkins Build Triggers]]></title>
            <link>https://faun.pub/configuring-jenkins-build-triggers-cffc6fc1aa36?source=rss-37229d01f38------2</link>
            <guid isPermaLink="false">https://medium.com/p/cffc6fc1aa36</guid>
            <category><![CDATA[devops-practice]]></category>
            <category><![CDATA[jenkinsfile]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Alparslan Uysal]]></dc:creator>
            <pubDate>Sat, 22 Mar 2025 15:10:14 GMT</pubDate>
            <atom:updated>2025-03-22T15:10:14.438Z</atom:updated>
            <content:encoded><![CDATA[<h4>Secure Build — DevSecOps Series</h4><p>Build triggers are structures that automate the building and deployment of a project by triggering the build or deployment as a result of specific conditions or events. With build triggers, the project can be automatically built and deployed, reducing the feedback time for potential errors during the build step and freeing the operations teams from a manual process during the deployment step through automatic deployment.</p><p>With build triggers, a build can be triggered after a change in the source control repository, at specific intervals, or via webhooks by external requests. You can choose different build trigger options based on the project’s needs. The most commonly preferred trigger type is automatically triggering the build after a change in the source control repository, as it provides the fastest feedback to the software teams, allowing them to see and act on build-related errors immediately. This blog post will explain how to configure automatic build triggering in Jenkins and GitHub repository.</p><p><strong>Github configuration</strong></p><p>First, we need to set up build trigger settings in the repository we are working on. With these settings, when a commit is made to the repository, the source control system will take action and trigger a build that we will prepare in Jenkins.</p><p>To allow Jenkins to access our git repository, we need to create a token on the GitHub side. The permissions of this token should be limited according to the task. In this pipeline, since we will only fetch the code from the git repository and build it, read access for specific repositories will be sufficient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qUyPbuVE-QW8zpMkv4cmYw.png" /></figure><p>After creating the token, make sure to store it securely, as you will not be able to access it again from GitHub. Additionally, configure this token in Jenkins under the Jenkins Configuration section to connect Jenkins to your GitHub account.</p><p>The second action we need to take on the GitHub side is setting up a webhook. This webhook configuration will trigger the Jenkins pipeline upon a commit made to the repository. To set up the webhook, follow these steps:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j2whArmGcuKNpiimBk9YcA.png" /></figure><p>We need to add the Jenkins URL to the Payload URL field and /github-webhook/ at the end.</p><p>For the event configuration, since we only want to trigger the webhook on push events, selecting “Just the push event” is sufficient. You can adjust this based on your specific needs.</p><p>After creating the webhook, on the Webhooks page, you should see a green checkmark icon next to the webhook definition. This icon indicates a successful connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oQsAZYbebr2_SDUpHHrmqA.png" /></figure><p>Finally, we need to create a Jenkinsfile in our Git repository. A Jenkinsfile is a manifest that contains build steps and specifies the steps to be taken when building a software product. Keeping the build script in the source control system is crucial for tracking configuration changes. You can place the Jenkinsfile in the root directory of your project as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m1N3vbQ_E3Y8f6QCzqnMBQ.png" /></figure><p><strong>Jenkins Configuration</strong></p><p>In the Jenkins Configuration section, there are two tasks we need to complete. Firstly, we need to register the Git token we previously created with Jenkins. Secondly, we need to configure the pipeline.</p><p>To establish the Jenkins-GitHub connection, you need to define the GitHub server in Jenkins by Jenkins → Manage Jenkins → Configure System page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8dCfEmLSryctGYzBOHdQhw.png" /></figure><p>When you click on “Add” to add credentials for your GitHub token in Jenkins, you’ll see a screen like:</p><p><strong><em>Kind</em></strong><em>:</em> Select “Secret text” from the dropdown.</p><p><strong><em>Secret</em></strong><em>:</em> Enter the GitHub token you previously created in the “Secret” field.</p><p><strong><em>ID</em></strong><em>:</em> Provide an ID for this credential entry (e.g., github-token).</p><p><strong><em>Description</em></strong><em>:</em> Optionally, provide a descriptive name or label for the credential entry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sos3_BzJ3UCKtmKy5jzWog.png" /></figure><p>After creating the credential, you can confirm a successful connection by clicking Test connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*__-Hmmmr6r0V15mACiyeIQ.png" /></figure><p>Finally, we need to configure Pipeline. We can create a pipeline in Jenkins to receive the Jenkinsfile from SCM as follows. First, we need to click on the Configure Jenkins pipeline option and select the Github hook trigger for GITScm polling option under the Build Trigger tab. As stated in the description, this option runs the job by comparing it with the SCM information defined in the job when the Github Webhook runs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V2ql55fMLa6f3OtMfkEQrg.png" /></figure><p>In the Pipeline configuration field, the Pipeline script from SCM option should be selected. When this option is activated, a field will appear where we can enter the repository in which the Jenkinsfile is located, credential information if it is a private repository, which branch to build from in the Branches to build field, and the Jenkinsfile path information in the repository in the Script path field. We can configure the configuration as shown in the picture below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wg5YwwItt6fU67sCSLk4Wg.png" /></figure><p>When we save the pipeline, a commit we make in the git repository will automatically trigger the job.</p><p>Not: In this example, a Java Spring Boot application will be built based on the Dockerfile found in the repository. Docker has been installed on the build server. If you intend to build a Docker image for an application, you need to install Docker on your build server as well. You can follow the installation instructions at <a href="https://docs.docker.com/engine/install/ubuntu/">https://docs.docker.com/engine/install/ubuntu/</a>. If you are not using Docker, you can execute a shell script in the Build stage to build your application.</p><pre>pipeline { <br>    agent any <br>    options {<br>        skipStagesAfterUnstable()<br>    }<br>    stages {<br>        <br>        stage(&#39;Build&#39;){<br>            steps {<br>                sh &#39;docker build -t springbootdemo:latest .&#39;<br>            }<br>        }<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*D2Moo3Vyts0Q1pCHMxADlg.png" /></figure><p><em>Thank you for reading my blog post! Do you have any additional tips or strategies for CI pipelines? I’m eager to hear your insights. </em><a href="https://twitter.com/uysal_alparslan"><em>Connect with me on Twitter!</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*JPV3iHtxPbNWTS9u.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cffc6fc1aa36" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/configuring-jenkins-build-triggers-cffc6fc1aa36">Configuring Jenkins Build Triggers</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Strengthening Your CI Pipeline]]></title>
            <link>https://faun.pub/strengthening-your-ci-pipeline-b9449ca92767?source=rss-37229d01f38------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9449ca92767</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[devsecops]]></category>
            <category><![CDATA[continious-integration]]></category>
            <dc:creator><![CDATA[Alparslan Uysal]]></dc:creator>
            <pubDate>Sat, 22 Mar 2025 15:10:07 GMT</pubDate>
            <atom:updated>2025-03-22T15:10:07.247Z</atom:updated>
            <content:encoded><![CDATA[<h4>Secure Build — DevSecOps Series</h4><p>CI is an SDLC process that manages the integration of features developed by developers into environments according to organizational principles. Having a central CI server and standard test, quality, and security processes managed by specific automation systems ensures the integration of secure, high-quality, and fully tested work into environments. By adhering to one of DevOps’ most important practices, which is to automate everything as much as possible, automating our processes ensures secure integration and prevents potential chaos situations.</p><p>Popular CI tools like Jenkins make it easy to design and manage build automation tasks. Jenkins supports Continuous Integration by integrating with SCM systems. With the webhook feature, it can automatically start the build process when a developer commits to source control.</p><p>Organizations typically use one or more options for build automation tasks such as manual trigger, scheduled build, or automatic trigger. In this blog series, we will share the benefits and practice of an automatically triggered SDLC process. Additionally, the most important feature of an automatic build is providing the fastest possible feedback to the developer regarding the build. Build feedback quickly informs the developer about the success or failure of their work, allowing immediate action in case of errors. In contrast, scheduled builds or manual builds will extend the feedback time.</p><p>Build automation is triggered by a commit to source control, after which the build process begins. The application is built, unit tests written for the application are run, quality tests are conducted, and security tests are performed. Finally, the created artifact, which could be a Docker image, jar file, or another type of file, is integrated into the systems. The process is generally as shown in the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yvXFkkPYW98wTvVvgnmMDA.png" /></figure><p>Developers can view and receive feedback on the build processes from the Jenkins console. In the Secure Build series, we will prepare an example pipeline to automate the processes.</p><p>In the first step, we will define the necessary configurations to trigger the build process with a commit to the source control and perform the application build (Build Trigger).</p><p>In the second series, we will make the necessary adjustments in the pipeline to run the unit tests written for our application and report the unit tests (Unit Testing).</p><p>In the third series, we will configure the necessary settings for the quality tests of our application, integrate them into the pipeline, and report them on Sonarqube.</p><p>In the fourth step, we will scan our application with security tools and perform security tests.</p><p>In the final step, we will deploy the artifact, which has passed various tests during the build process, to the staging environment.</p><p>You can follow all the steps in the Secure Build — DevSecOps series.</p><p><em>Thank you for reading my blog post! Do you have any additional tips or strategies for CI pipelines? I’m eager to hear your insights. </em><a href="https://twitter.com/uysal_alparslan"><em>Connect with me on Twitter!</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*JPV3iHtxPbNWTS9u.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9449ca92767" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/strengthening-your-ci-pipeline-b9449ca92767">Strengthening Your CI Pipeline</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Image Build to Distribution: Configuring Nexus as Your Docker Registry]]></title>
            <link>https://faun.pub/image-build-to-distribution-configuring-nexus-as-your-docker-registry-b50bfd555b07?source=rss-37229d01f38------2</link>
            <guid isPermaLink="false">https://medium.com/p/b50bfd555b07</guid>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[nexus]]></category>
            <category><![CDATA[continious-integration]]></category>
            <dc:creator><![CDATA[Alparslan Uysal]]></dc:creator>
            <pubDate>Fri, 31 Jan 2025 12:45:56 GMT</pubDate>
            <atom:updated>2025-01-31T12:45:56.651Z</atom:updated>
            <content:encoded><![CDATA[<p>Docker registry is a repository that allows us to manage and distribute container images. We can use two different types of Docker registries: private and public. If we want to distribute our application publicly, we can work with a registry like DockerHub. However, for commercial applications, it is preferable to use a private registry. Many organizations prefer using a private container registry to speed up build times and simplify management and distribution. In previous blogs, we discussed the installation and configuration of Nexus repository. In this blog, we will explore building the container image we created using a private registry and managing it in Nexus repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7d6ojqaRZKRufz_2xfiJFw.png" /></figure><p><strong>Nexus Repository Configuration</strong></p><p>Nexus and similar private registries offer a crucial advantage with their caching feature. Through a Nexus proxy repository, when we download a component (such as an image) from a public registry, Nexus caches this component. For subsequent download requests, Nexus serves the component from its cache to the client. This significantly reduces download times, thereby speeding up build times as well. To utilize the caching feature and store base images in Nexus, you need to create a Docker Proxy repository type. Additionally, for distributing the container images you create, you should set up a Docker Hosted repository type. We’ve previously discussed creating proxy and hosted repositories in the blog; you can refer to those details for more information.</p><p><strong>Nexus User Privileges</strong></p><p>In Nexus, it’s essential to create a user specifically for clients to connect to the repository. This user should have permissions to connect to the Nexus repository and perform tasks like downloading and uploading images. To enhance security, it’s advisable to create a user with limited privileges rather than using a powerful user like admin. When assigning these privileges, it’s crucial to follow the principle of least privilege, granting only the permissions necessary for the tasks required.</p><p><strong>Docker Client Configuration</strong></p><p>To configure the Docker client on the build server to connect to the proxy and hosted repositories over HTTP instead of HTTPS, you need to edit the /etc/docker/daemon.json file. Here is how you can edit this file for each repository:</p><pre>sudo vi /etc/docker/daemon.json</pre><pre>{<br>  &quot;insecure-registries&quot;: [<br>    &quot;&lt;nexus host name&gt;:&lt;proxy repository port&gt;&quot;,<br>    &quot;&lt;nexus host name&gt;:&lt;hosted repository port&gt;&quot;<br>  ]<br>}</pre><p>Replace &lt;nexus host name&gt; and &lt;repository port&gt; with the actual URLs of your proxy and hosted repositories respectively.</p><p>After making these changes, restart the Docker daemon for the changes to take effect:</p><p>As for the nexus user we created, we need to log in to the container registry from a server where the build server or docker client is installed, as follows. Docker client reads authentication information from the ~./docker/config.json file on the server. If the authentication information is not in this file, we need to log in with the docker login command for each repository. You can log in to proxy and hosted docker repositories separately as follows.</p><pre>docker login &lt;nexus host name&gt;:&lt;repository port&gt;</pre><p>Nexus host name must be the IP address where the nexus repository is installed. The repository port address must be the port we specified when creating the proxy and hosted repository.</p><p>After successful login, records with authentication information for each repository will be added to the ~./docker/config.json file and stored in this file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*KILEuPNq7uPCWDRrReXhUg.png" /></figure><p>You can download a sample image via the nexus proxy repository as follows.</p><pre>docker pull &lt;nexus host name&gt;:&lt;repository port&gt;/nginx:latest</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*9k6LX7VzXTNPtF3T7h3Wyg.png" /></figure><p><strong>Get Base Image From Registry</strong></p><p>We created a proxy repository to improve build times and store the base images we used. In previous series, we examined the steps of creating a container image with Dockerfile. In this step, we will pull the base images we use in the Dockerfile using the internal nexus proxy repository, not from the internet. You can update the sample Dockerfile as follows.</p><pre>#Build stage<br>FROM 172.31.113.68:8082/maven:3-eclipse-temurin-11 as build<br><br>WORKDIR /workspace/app<br><br>COPY pom.xml .<br>COPY src src<br><br>RUN mvn clean install<br>RUN mkdir target/extracted<br>RUN java -Djarmode=layertools -jar target/*.jar extract --destination target/extracted<br><br>#Runtime stage<br>FROM 172.31.113.68:8082/eclipse-temurin:11-jdk-alpine<br><br>ARG EXTRACTED=/workspace/app/target/extracted<br><br>COPY --from=build ${EXTRACTED}/dependencies/ ./<br>COPY --from=build ${EXTRACTED}/spring-boot-loader/ ./<br>COPY --from=build ${EXTRACTED}/snapshot-dependencies/ ./<br>COPY --from=build ${EXTRACTED}/application/ ./<br><br>ENTRYPOINT [&quot;java&quot;,&quot;org.springframework.boot.loader.JarLauncher&quot;]</pre><p>Thus, we will always have access to the base images we use since they are kept in the nexus repository, and thanks to the cache feature, we will be able to download the base images quickly without going to the internet.</p><p><strong>Publishing to Registry</strong></p><p>We can version the container image we created and keep it in the internal registry. In this way, we can distribute and store the application we have developed privately within the organization. When we push the image to the docker-hosted repository we created in Nexus, the container image will be ready for distribution to platforms and teams.</p><p>To create the container image, we can run the following command in the project root directory. Since we will push the container image to the Dockerhosted repository, we need to give the port of the hosted repository.</p><pre>docker build -t 172.31.113.68:8083/springbootdemo:1.0.0 .</pre><p>We can see the image we created with the docker images command. To push to the hosted repository, we must run a command like the following.</p><pre>docker push 172.31.113.68:8083/springbootdemo:1.0.0</pre><p>After pushing, you can view the container image by going to the nexus web interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*MJTmEY68YrlR4Abcfz3u-g.png" /></figure><p>By configuring proxy and hosted repositories, fine-tuning user privileges, and properly setting up Docker clients, you can streamline your container management processes while benefiting from Nexus’s caching capabilities.</p><p><em>Thank you for reading my blog post! Do you have any additional tips or strategies for Image Build Processes? I’m eager to hear your insights. </em><a href="https://twitter.com/uysal_alparslan"><em>Connect with me on Twitter!</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*aUyN6YOrWzsxBQmw.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b50bfd555b07" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/image-build-to-distribution-configuring-nexus-as-your-docker-registry-b50bfd555b07">Image Build to Distribution: Configuring Nexus as Your Docker Registry</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Application Containerization: A Beginner’s Guide]]></title>
            <link>https://faun.pub/application-containerization-a-beginners-guide-f251331268dd?source=rss-37229d01f38------2</link>
            <guid isPermaLink="false">https://medium.com/p/f251331268dd</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Alparslan Uysal]]></dc:creator>
            <pubDate>Fri, 31 Jan 2025 12:42:14 GMT</pubDate>
            <atom:updated>2025-01-31T12:42:14.522Z</atom:updated>
            <content:encoded><![CDATA[<p>Many organizations are transitioning from monolithic design to microservices design to improve their development and operations processes. In a microservices architecture, a single application is divided into smaller services based on their functionalities. These small services allow independent development without affecting other services. During the transformation of applications to microservices, all dependencies of the application, such as the operating system, packages, and libraries, are packaged into a single Docker image. This Docker image, containing all dependencies, can run on any platform. In this blog post, we will explain how to containerize a standard Java Spring Boot application and highlight some security considerations when creating the container image.</p><p>To containerize an application, you need a container engine installed on your operating environment or server. You can choose from popular container engines like Docker, Podman, etc., based on your needs. However, we will be using Docker in this blog. To install Docker on your server, you can refer to the detailed installation documentation on Docker’s official website (<a href="https://docs.docker.com/engine/install/">https://docs.docker.com/engine/install/</a>). The documentation provides detailed installation instructions for various operating systems. After completing the installation, you should also follow the post-installation steps to proceed to the container image creation stage (<a href="https://docs.docker.com/engine/install/linux-postinstall/">https://docs.docker.com/engine/install/linux-postinstall/</a>).</p><p>An example Spring Boot application is available on GitHub. You need to clone this repository to your working environment as follows:</p><p>This will clone the sample Spring Boot application repository to your local environment, where you can proceed with the containerization process.</p><pre>git clone https://github.com/alparslanuysal/springbootdemo.git</pre><p>This project already contains a pre-written Dockerfile necessary for containerizing the Spring Boot application. The Dockerfile includes the instructions required to convert the application into a container. Based on the steps specified in the Dockerfile, the container image is created.</p><p>Here is the Dockerfile:</p><pre>#Build stage<br>FROM maven:3-eclipse-temurin-11 as build<br><br>WORKDIR /workspace/app<br><br>COPY pom.xml .<br>COPY src src<br><br>RUN mvn clean install<br>RUN mkdir target/extracted<br>RUN java -Djarmode=layertools -jar target/*.jar extract --destination target/extracted<br><br>#Runtime stage<br>FROM eclipse-temurin:11-jdk-alpine<br><br>ARG EXTRACTED=/workspace/app/target/extracted<br><br>COPY --from=build ${EXTRACTED}/dependencies/ ./<br>COPY --from=build ${EXTRACTED}/spring-boot-loader/ ./<br>COPY --from=build ${EXTRACTED}/snapshot-dependencies/ ./<br>COPY --from=build ${EXTRACTED}/application/ ./<br><br>ENTRYPOINT [&quot;java&quot;,&quot;org.springframework.boot.loader.JarLauncher&quot;]</pre><p>Structurally examining the Dockerfile, the first thing to note is that it should be in a multi-stage format. In a multi-stage setup, the Dockerfile contains multiple FROM statements, each representing a different stage. The final stage in the Dockerfile will be the one used for the final container image, and the packages in this stage will be the only ones included in the final image. This Dockerfile contains two different stages: the build stage and the runtime stage.</p><p>The primary advantage of this setup is that it ensures only the necessary packages for running the application are included in the runtime. Including build, test, and other packages in the runtime can pose security risks. Therefore, we create the build artifact in the build stage and copy the artifact needed for running the application into the runtime stage, ensuring that no build-related packages are present in the final image.</p><p>Another advantage of multi-stage builds is that by only including the necessary packages in the final image, the image size is smaller compared to a basic Dockerfile. This results in a more efficient and secure container image.</p><h4>Build stage ;</h4><pre>#Build stage<br>FROM maven:3-eclipse-temurin-11 as build<br><br>WORKDIR /workspace/app<br><br>COPY pom.xml .<br>COPY src src<br><br>RUN mvn clean install<br>RUN mkdir target/extracted<br>RUN java -Djarmode=layertools -jar target/*.jar extract --destination target/extracted</pre><p>In the build stage, the necessary steps to build the application are performed. Optimizing the build step is crucial for speeding up the container build process. In the example below, the required files for the build are copied into the Docker image using the COPY command. It&#39;s important to ensure that only the necessary files are copied into the Docker image. A common mistake is to copy all files in the root directory into the container image.</p><p>If all files are copied into the container using COPY . ., Docker creates a layer for this instruction, and any change in the root directory will trigger this build step again, increasing the build time. For an optimized build, copying files such as pom.xml and source code is sufficient for most build scenarios in a Java project.</p><pre>COPY pom.xml .<br>COPY src src</pre><p>To optimize build times, as explained above, it’s important to leverage cached layers as much as possible. To use layers effectively, common steps used by multiple applications should be defined in separate instructions in the Dockerfile. This way, when building other applications, these common steps will be retrieved from the cache, speeding up the build process.</p><p>When we build our application, library dependencies do not change frequently, whereas the source code we write does. With the layer index feature provided by Spring Boot, the source code and dependencies are indexed separately. Therefore, a change in the application source code will not affect the library dependencies, and only the changed area will be included in the build process.</p><pre>RUN java -Djarmode=layertools -jar target/*.jar extract --destination target/extracted</pre><h4>Runtime stage;</h4><pre>#Runtime stage<br>FROM eclipse-temurin:11-jdk-alpine<br><br>ARG EXTRACTED=/workspace/app/target/extracted<br><br>COPY --from=build ${EXTRACTED}/dependencies/ ./<br>COPY --from=build ${EXTRACTED}/spring-boot-loader/ ./<br>COPY --from=build ${EXTRACTED}/snapshot-dependencies/ ./<br>COPY --from=build ${EXTRACTED}/application/ ./<br><br>USER 1001<br><br>ENTRYPOINT [&quot;java&quot;,&quot;org.springframework.boot.loader.JarLauncher&quot;]</pre><p>The step that prepares the final state of the container image is crucial, as any installations or authorizations performed here will be included in the final image. Given its impact on the final image, it’s important to handle this step with care. The most critical point to consider is not running the container as the root user to ensure the security of our application. If we do not create a specific user to run our application, the system will default to running the process as the root user, exposing our application to potential security vulnerabilities.</p><p>Therefore, it is essential to define an application user and assign the necessary permissions to this user for running our application.</p><pre>USER 1001</pre><p>In the runtime stage, the container image reaches its final state, so only the packages necessary for running the application should be included in this stage. These packages are copied from the image created in the build step. If any additional packages or libraries are needed, they can be added to the container image in this step.</p><pre>COPY --from=build ${EXTRACTED}/dependencies/ ./<br>COPY --from=build ${EXTRACTED}/spring-boot-loader/ ./<br>COPY --from=build ${EXTRACTED}/snapshot-dependencies/ ./<br>COPY --from=build ${EXTRACTED}/application/ ./</pre><p>To avoid potential security vulnerabilities, it’s crucial to use a minimal, stable, and official image from a reputable repository for the runtime stage. A common mistake is using the same base image for both the build and runtime stages. In the build step, a base image that contains all necessary packages for building the application is used. However, for the runtime stage, it’s important to use a different minimal base image that includes only the essential packages needed for running the application.</p><pre>#Runtime stage<br>FROM eclipse-temurin:11-jdk-alpine</pre><p>In this blog post, we followed the steps to effectively create a container image for a sample Spring Boot application. However, you can create container images for projects written in other languages, such as Python, Node.js, or .NET</p><p><em>Thank you for reading my blog post! Do you have any additional tips or strategies for Application containerization? I’m eager to hear your insights. </em><a href="https://twitter.com/uysal_alparslan"><em>Connect with me on Twitter!</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*aUyN6YOrWzsxBQmw.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f251331268dd" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/application-containerization-a-beginners-guide-f251331268dd">Application Containerization: A Beginner’s Guide</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Guide to SonarQube and SonarLint]]></title>
            <link>https://blog.devops.dev/a-guide-to-sonarqube-and-sonarlint-cdaf63a2a700?source=rss-37229d01f38------2</link>
            <guid isPermaLink="false">https://medium.com/p/cdaf63a2a700</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[sonarqube]]></category>
            <category><![CDATA[sdlc]]></category>
            <category><![CDATA[sonarlint]]></category>
            <dc:creator><![CDATA[Alparslan Uysal]]></dc:creator>
            <pubDate>Tue, 10 Sep 2024 15:15:33 GMT</pubDate>
            <atom:updated>2024-09-10T15:15:33.197Z</atom:updated>
            <content:encoded><![CDATA[<p>Sonarqube is a tool for developers that scans codebase, identifies potential code smells, spots bugs, and even raises a red flag if it detects any security risks. It also spots code duplication. Sonarqube employs static analysis, a method that examines your source code without actually executing the program. This proactive approach allows Sonarqube to catch potential issues early in the development process.</p><p>To provide a high-quality development environment, integrating SonarQube into our toolchain will significantly reduce our project’s maintenance costs and bugs. When integrating SonarQube into our system, the first step is to define quality standards at the organizational and team levels. SonarQube introduces the concept of quality gates, which are customizable sets of criteria that your code must meet before it can proceed to further development or deployment. These gates serve as a safeguard, ensuring that your code adheres to predefined quality standards.</p><p>Once quality standards are established, determining where checkpoints will be placed, providing feedback to developers, and regularly generating quality reports are crucial for organizational improvement. SonarQube offers various methods for integration. The entry point of integration should facilitate developers receiving feedback as early as possible, and SonarQube can be added as a plugin to many IDEs, providing useful feedback during the initial stages of development through static analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*Uyw2hIEYEHzmAXz8Tk6u6Q.png" /></figure><p>In this blog post, we will integrate SonarLint into Eclipse IDE. After opening your Eclipse IDE, navigate to Help &gt; Eclipse Marketplace. In the “Find” field, type “SonarLint” and install the plugin as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aYbCsdvuEea6oSCczPpGiw.png" /></figure><p>After completing the installation process, SonarLint will become active in your IDE after you restart it.</p><p>One of SonarQube’s strengths is its seamless integration with Continuous Integration and Continuous Deployment (CI/CD) pipelines. By incorporating SonarQube into your CI/CD workflow, you can automatically trigger code analyses and receive immediate feedback on the quality of your code as part of the development process. We will delve into integrating SonarQube with CI pipelines in detail in future installments of the blog post series.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6eW9x0LKJE6N7Nexj3ucXg.png" /></figure><p>It’s all about empowering your code. SonarQube isn’t just a tool; it’s your co-pilot, your sidekick, and your go-to friend in the coding trenches. By integrating it into your projects, you’re not just ensuring that your code is bug-free and secure, but you’re also setting the stage for a development process that’s efficient, collaborative, and downright enjoyable.</p><p><em>Thank you for reading my blog post! Do you have any additional tips or strategies for Coding Standards? I’m eager to hear your insights. </em><a href="https://twitter.com/uysal_alparslan"><em>Connect with me on Twitter!</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cdaf63a2a700" width="1" height="1" alt=""><hr><p><a href="https://blog.devops.dev/a-guide-to-sonarqube-and-sonarlint-cdaf63a2a700">A Guide to SonarQube and SonarLint</a> was originally published in <a href="https://blog.devops.dev/">DevOps.dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with SonarQube: A Step-by-Step Installation Guide]]></title>
            <link>https://blog.devops.dev/getting-started-with-sonarqube-a-step-by-step-installation-guide-2feb28439aff?source=rss-37229d01f38------2</link>
            <guid isPermaLink="false">https://medium.com/p/2feb28439aff</guid>
            <category><![CDATA[quality-software]]></category>
            <category><![CDATA[sonarqube]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Alparslan Uysal]]></dc:creator>
            <pubDate>Tue, 10 Sep 2024 15:13:28 GMT</pubDate>
            <atom:updated>2024-09-10T15:13:28.824Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cgTrR_bhRDba7RsH-etajQ.png" /></figure><p>In a previous series, we discussed the integration steps of SonarQube to improve code quality. In this blog post, we will install and configure SonarQube in our own environment and, by the end of the blog, run a simple analysis.</p><p><strong>Prerequisites:</strong></p><p>BefFore starting the installation, we need to ensure certain prerequisites for setting up SonarQube. The first requirement is that SonarQube is a Java application, so the server where it will be installed needs to have Java installed.</p><p>If Java is not installed on your server, you can complete the installation as follows:</p><pre>sudo apt update<br>sudo apt install -y openjdk-17-jre<br>java -version</pre><p>The second requirement is to install an external database. SonarQube comes with an embedded database for default installations, which is suitable for proof of concept purposes. However, for production use to avoid scalability issues and facilitate version upgrades smoothly, it is recommended to install an external database. Options like MSSQL, Oracle, and PostgreSQL are available, but for this blog post, we will choose PostgreSQL due to its open-source nature and efficiency.</p><p>You can follow the steps below to install PostgreSQL on your server. We’ll install PostgreSQL 13, but you can choose a different version based on your needs.</p><pre>sudo sh -c &#39;echo &quot;deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main&quot; &gt; /etc/apt/sources.list.d/pgdg.list&#39;<br><br>wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -<br><br>sudo apt-get update<br><br>sudo apt-get -y install postgresql-13<br><br>sudo systemctl is-enabled postgresql<br><br>sudo systemctl status postgresql</pre><p>For demo purposes, we will install PostgreSQL on the same server as SonarQube. However, it’s generally recommended to separate the database and application onto different servers for easier management of patches and scalability.</p><p>After completing the PostgreSQL installation, you’ll need to create a schema and a user named “sonarqube” in PostgreSQL. This user should be granted permissions to create, update, and delete objects within the “sonarqube” schema.</p><p>To grant permissions to a PostgreSQL user, you can open a psql shell with the PostgreSQL user and then assign privileges.</p><pre>sudo -u postgres psql</pre><pre>CREATE USER sonarqube WITH PASSWORD &#39;6gkrBybt&#39;;<br>CREATE DATABASE sonarqube OWNER sonarqube;<br>GRANT ALL PRIVILEGES ON DATABASE sonarqube TO sonarqube;<br><br>#exit psql shell<br>\q</pre><p>Creating a dedicated user for SonarQube will be beneficial. You can create and configure the user as follows:</p><pre>#Create a sonarqube user<br>sudo useradd -b /opt/sonarqube -s /bin/bash sonarqube</pre><pre>#Open file with vi add below configuration end of the file<br>sudo vi /etc/sysctl.conf</pre><pre>vm.max_map_count=524288<br>fs.file-max=131072</pre><p>Save and exit the file and apply new changes with command:</p><pre>sudo sysctl --system</pre><p>Also, apply the ulimit command:</p><pre>ulimit -n 131072<br>ulimit -u 8192</pre><p>Add following lines in the configuration file:</p><pre>sudo vi /etc/security/limits.d/99-sonarqube.conf</pre><pre>sonarqube   -   nofile   131072<br>sonarqube   -   nproc    8192</pre><p><strong>Installation :</strong></p><p>We have completed the necessary steps for SonarQube, and now we will download and install SonarQube from a zip file. Additionally, we will configure it to run as a service on Linux and set it up to run behind a proxy.</p><p>You can use the following commands to download the SonarQube binary file and grant permissions to the user.</p><pre>#Install sonarqube binary<br>wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-10.3.0.82913.zip<br><br>#Unzip the downloaded file<br>unzip sonarqube-10.3.0.82913.zip<br><br>#Move the files sonarqube home dir<br>sudo mv sonarqube-10.3.0.82913 /opt/sonarqube<br><br>#Change ownerhip of the folder<br>sudo chown -R sonarqube:sonarqube /opt/sonarqube</pre><p>We have completed the installation steps, and now we need to configure SonarQube to use the newly created PostgreSQL database. After opening the configuration file, we will edit the sonar.jdbc.username, sonar.jdbc.password, and sonar.jdbc.url fields. You can use the following commands to open and edit the configuration file:</p><pre>#Open sonarqube conf file<br>sudo vi /opt/sonarqube/conf/sonar.properties<br><br>#Uncommet the below lines and add your credentials<br>sonar.jdbc.username=sonarqube<br>sonar.jdbc.password=6gkrBybt<br><br>#Uncommmet the jdbc url section under postgresql<br>sonar.jdbc.url=jdbc:postgresql://localhost/sonarqube<br><br>#Also change uncomment the blow lines and edit web host and port<br>sonar.web.host=127.0.0.1<br>sonar.web.port=9000</pre><p>We have completed the basic configuration of SonarQube, but you can further configure it based on your needs, such as JVM parameters, logging configuration, and more.</p><p><strong>Run Sonarqube as a Service:</strong></p><p>To simplify the management of SonarQube, we will define a Linux service as follows. You can create a new service file and add the configuration below:</p><pre>sudo vi /etc/systemd/system/sonarqube.service</pre><pre>[Unit]<br>Description=SonarQube service<br>After=syslog.target network.target<br><br>[Service]<br>Type=forking<br>ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start<br>ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop<br>User=sonarqube<br>Group=sonarqube<br>Restart=always<br>LimitNOFILE=65536<br>LimitNPROC=4096<br><br>[Install]<br>WantedBy=multi-user.target</pre><p>After creating the service file, you can enable and start the service as follows:</p><pre>sudo systemctl daemon-reload<br>sudo systemctl start sonarqube.service<br>sudo systemctl enable sonarqube.service<br>sudo systemctl status sonarqube.service</pre><p><strong>Run Sonarqube behind a proxy :</strong></p><p>Running Sonarqube behing a proxy offers several benefits, enhancing the overall performance, security, and manageability of sonarqube instance. Some key advantages are SSL/TLS termination, Load balancing and caching, access logging etc.</p><p>We will install nginx as a web proxy and direct incoming requests to sonarqube. You can install nginx on the server as follows.</p><pre>sudo apt install -y nginx<br>sudo systemctl is-enabled nginx<br>sudo systemctl status nginx</pre><p>To set up nginx as a web proxy to route requests to SonarQube, you can install nginx on your server as follows:</p><pre>sudo vi /etc/nginx/sites-available/sonarqube.conf</pre><p>You can add the following configuration to the sonarqube.conf file. This file simply directs HTTP requests on the specified port to SonarQube. However, you can enhance security by adding your SSL certificate.</p><pre>server {<br><br>    listen 80;<br>    #server_name sonar.example.com;<br>    access_log /var/log/nginx/sonar.access.log;<br>    error_log /var/log/nginx/sonar.error.log;<br>    proxy_buffers 16 64k;<br>    proxy_buffer_size 128k;<br><br>    location / {<br>        proxy_pass http://127.0.0.1:9000;<br>        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;<br>        proxy_redirect off;<br>        proxy_set_header Host $host;<br>        proxy_set_header X-Real-IP $remote_addr;<br>        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>        proxy_set_header X-Forwarded-Proto http;<br>    }<br>}</pre><p>After saving the file, you need to test the nginx configuration and restart the service as shown below:</p><pre>sudo ln -s /etc/nginx/sites-available/sonarqube.conf /etc/nginx/sites-enabled/<br>sudo nginx -t<br><br>#Disable the default nginx welcome page.<br>sudo unlink /etc/nginx/sites-enabled/default<br>sudo rm /etc/nginx/sites-available/default<br><br><br>sudo systemctl restart nginx</pre><p>Finally, open a web browser and enter the IP address of your SonarQube server. You will see a login screen where you should enter “admin” for both the username and password fields by default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*E0EAYyzADlAH3-mruG9ZZA.png" /></figure><p>When you click the “Log in” button, you will be prompted to update the password for the admin user. You can set a suitable password for the admin user on that screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*PrMxoS6o0NsWeGqyuH9oiQ.png" /></figure><p>SonarQube’s homepage will appear as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NnHScQoXXIkRq83dYBFX1w.png" /></figure><p><strong>Integration with code :</strong></p><p>To initiate code analysis, install a compatible scanner. SonarQube supports a variety of official scanners. Choose one that aligns with your technological stack. In this example, we’ll perform a SonarQube scan using Maven.</p><p>Maven needs to be installed on your build server. If it’s not installed, you can do so as follows:</p><pre>wget https://dlcdn.apache.org/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz<br><br>tar -xvzf apache-maven-3.9.6-bin.tar.gz<br><br>sudo mv apache-maven-3.9.6 /opt/<br><br>#Open .profile file in the user home dir<br>vi .profile<br><br>#Add below lines end of the file<br><br>M2_HOME=&#39;/opt/apache-maven-3.9.6&#39;<br>PATH=&quot;$M2_HOME/bin:$PATH&quot;<br>export PATH<br><br>#Relaunch terminal with below command<br>source .profile<br><br>#Check maven version<br>mvn -version</pre><p>Before initiating the analysis, we need to generate an access token in the SonarQube web interface as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VmmGjr2FNdKtnR6pJ4WTRQ.png" /></figure><p>We will use the token we generate for code analysis. Once the token is created, we won’t have another chance to view it, so make sure to store it securely in a password manager.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Czq-VWkZV4J3CuyFwkTgMw.png" /></figure><p>We can clone our example project from GitHub to the server using git clone and then start the SonarQube analysis.</p><pre>git clone https://github.com/alparslanuysal/springbootdemo.git<br><br>#Go to project dir<br>cd springbootdemo<br><br><br>#Run below command<br>#-Dsonar.host.url specifies the sonarqube instance, -Dsonar.token specifies the token we created before for scanner<br>mvn clean verify sonar:sonar -Dsonar.host.url=http://http://157.56.167.104 -Dsonar.token=sqa_7862271299797db3f8fc8412014fa6efe819936f</pre><p>After a successful scan, you can view the code quality report in the SonarQube web interface as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oATs7xBciZVA0KrG2FYEcg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VQyM1S3JL6zKZUr7ZGMvng.png" /></figure><p>This guide walks you through the straightforward steps to install SonarQube, setting the foundation for enhanced code analysis, bug detection, and security monitoring. Whether you’re a developer or a tech lead, this post will help you get started with SonarQube and elevate your code quality.</p><p><em>Thank you for reading my blog post! Do you have any additional tips or strategies for Sonarqube? I’m eager to hear your insights. </em><a href="https://twitter.com/uysal_alparslan"><em>Connect with me on Twitter!</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2feb28439aff" width="1" height="1" alt=""><hr><p><a href="https://blog.devops.dev/getting-started-with-sonarqube-a-step-by-step-installation-guide-2feb28439aff">Getting Started with SonarQube: A Step-by-Step Installation Guide</a> was originally published in <a href="https://blog.devops.dev/">DevOps.dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Guide to Efficient Kubernetes Cluster Setup with Kubespray]]></title>
            <link>https://faun.pub/guide-to-efficient-kubernetes-cluster-setup-with-kubespray-8a29c58b13a2?source=rss-37229d01f38------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a29c58b13a2</guid>
            <category><![CDATA[kubespray]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[ansible]]></category>
            <dc:creator><![CDATA[Alparslan Uysal]]></dc:creator>
            <pubDate>Sat, 07 Sep 2024 21:16:27 GMT</pubDate>
            <atom:updated>2024-09-07T21:16:27.137Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*0QQNxApw994Pc2MEv8B6hg.png" /></figure><p>In the modern development and deployment world, Kubernetes has become a standard and provides significant benefits to organizations in managing container applications.</p><p>Setting up a Kubernetes cluster can be a time-consuming and complex process, especially for beginners. The Kubernetes architecture and components can be challenging to grasp at first, and often we want to quickly set up an environment and start developing. In the modern world, to avoid wasting time on environment setups, we need to automate these processes to achieve quick results. Those managing Kubernetes clusters will greatly benefit from standardizing installations using automation tools instead of setting up all Kubernetes components one by one. With the automation of this process, installations in test, UAT, and production environments will become standardized, and you will spend much less time deploying to other environments after setting up one environment.</p><h4><strong>What is Kubespray?</strong></h4><p>Kubespray is an open-source application developed to automate Kubernetes installation and configuration processes. Kubespray fundamentally uses Ansible, a popular configuration management and automation tool. With Ansible’s declarative structure and idempotent nature, cluster installations become stable. One of the most important features of Kubespray is that you can perform Kubernetes installations regardless of the infrastructure. For example, you can easily set up a cluster on popular cloud providers like AWS, Azure, GCP, or on VMs in your on-prem environment. Additionally, Kubespray provides considerable flexibility in configuring Kubernetes. You can perform cluster installations using the default standard components or specify different solutions like networking, storage, etc., in the configuration file.</p><h4><strong>Preparing Your Environment</strong></h4><p>Before starting a Kubernetes installation, it’s necessary to carefully decide on aspects of the Kubernetes architecture, hardware, and software packages to be installed. First, you need to decide on the Kubernetes cluster architecture and determine the resources you will allocate for the cluster’s performance. The Kubernetes architecture consists of two basic structures: control plane nodes and worker nodes. Control plane nodes are servers that run Kubernetes components such as the API server, controller manager, and scheduler. To align with fault tolerance and redundancy concepts, there should be 2–3 control plane nodes. Worker nodes, on the other hand, are servers that will run containerized applications. The number and hardware requirements of these servers should be decided according to the CPU and memory values necessary for your applications to run, and to ensure an ideal structure that meets fault tolerance, at least 2–3 worker node servers should be set up. To reduce the risks that may arise from hardware failures, it is recommended to set up each control plane and worker node server in different locations.</p><p>In this blog, 1 control plane and 2 worker nodes will be set up for demonstration purposes. Additionally, we will install the necessary packages for Kubespray on a jumphost server that has network access to these servers, and the Kubernetes installation process will be carried out on the jumphost server. You can choose to perform the server installations in your on-prem environments or on any public cloud vendors like AWS or Azure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UwBWIyCjZKcENbdBhWcNkA.png" /></figure><h4><strong>Installing Kubespray</strong></h4><p>Since Kubespray uses Ansible, we will set up Kubespray on a different server (jumpbox) from the control plane, worker-node01, and worker-node02 servers allocated for the cluster installation. However, if you have access to the Kubernetes network from your local computer, you can also perform the Kubespray installation on your local computer for testing purposes.</p><p>Once the servers are ready, you can connect to the jumpbox server and proceed with the necessary steps for Kubespray installation.</p><p><strong><em>Generate and disrtibute ssh key</em></strong></p><p>The first step, since the installation will be done with Ansible, is to ensure that the jumpbox server has SSH key access to the other Kubernetes servers. To do this, we need to generate SSH keys on the jumpbox server and distribute them to the other servers using the following commands.</p><pre>ssh-keygen -t rsa<br><br>ssh-copy-id -p 22 demo@10.0.0.4<br>ssh-copy-id -p 22 demo@10.0.0.5<br>ssh-copy-id -p 22 demo@10.0.0.6</pre><p>We need to perform the SSH key copying for all the servers where the installation will be done. After running the ssh-copy-id command for each server, you will be able to connect to the Kubernetes servers without a password, as shown below.</p><pre>ssh -p &#39;22&#39; &#39;demo@10.0.0.4’</pre><p><strong><em>Install Kubespray requirements</em></strong></p><p>We need to install a few packages required for Kubespray. On the jumpbox server where Kubespray will be installed, we will start by installing Python.</p><pre>sudo apt update<br>sudo apt install python3<br>sudo apt install python3-pip</pre><p>You can clone the Kubespray repository as shown below and switch to the desired Kubespray version using <em>git checkout &lt;release&gt;</em>, then start the installation. In this example, we will use release-2.20.</p><pre>git clone https://github.com/kubernetes-sigs/kubespray.git<br>cd kubespray<br>git checkout release-2.20</pre><p>You can install the necessary software dependencies for Kubespray as follows.</p><pre>sudo pip3 install -r requirements.txt</pre><h4><strong>Configuring the Kubernetes Cluster</strong></h4><p>The default installation information is found in the <em>inventory/sample</em> file within the cloned repository. You can copy this information to a different directory as shown below, and then make the necessary configurations for the cluster in this directory.</p><pre>cp -rfp inventory/sample inventory/democluster</pre><p>After creating the new inventory directory, you can update the Ansible inventory file using the inventory builder as shown below. This command will add the IP addresses of the servers where the installation will be done to the <em>inventory/democluster/group_vars/all/all.yml</em> and <em>inventory/democluster/group_vars/k8s_cluster/k8s-cluster.yml</em> files.</p><pre>declare -a IPS=(10.0.0.4 10.0.0.5 10.0.0.6)<br>HOST_PREFIX=demo- KUBE_CONTROL_HOSTS=1 CONFIG_FILE=inventory/democluster/hosts.yaml python3 contrib/inventory_builder/inventory.py ${IPS[@]}</pre><p>The inventory builder will update the hosts in <em>inventory/democluster/hosts.yaml</em>. The <strong>HOST_PREFIX</strong> variable will add the specified prefix to the node names, and the <strong>KUBE_CONTROL_HOSTS</strong>=1 variable will designate one of the specified hosts as the control plane.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l-IlCQz3KuWutR4n95ZEcA.png" /></figure><p>If you prefer, you can update the node names by modifying the inventory/democluster/hosts.yaml file as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/329/1*_F9knxf9r3waLdY9RUy1uQ.png" /></figure><p>We have set up the necessary configuration for 1 control plane and 2 worker nodes according to the topology shared above.</p><p>In addition to this configuration, if you have any standards for other configurations like networking or etcd, you can modify the variables in the <em>inventory/democluster/group_vars/k8s_cluster/k8s-cluster.yml</em> folder within the inventory. Otherwise, Kubespray will perform the cluster installation with default values. To specify the Kubernetes cluster version you want to install, search for the <strong>kube_version</strong> variable in the same file and adjust the version.</p><pre>vi inventory/democluster/group_vars/k8s_cluster/k8s-cluster.yml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*l_jaT_eew9Nsl93_t0y_sw.png" /></figure><h4><strong>Deploying the Cluster</strong></h4><p>After completing the necessary installations and configurations, you can start the Kubernetes installation with Kubespray. The following Ansible command will test the connection to the hosts in the inventory. If you encounter an error at this stage, there might be an issue with your SSH key configurations.</p><pre>ansible -i inventory/democluster/hosts.yaml -m ping all</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*IIpVGdp84mXgXHELwyU7Ng.png" /></figure><p>If the connection is successful, you can start the cluster installation in the Kubespray directory using the following command:</p><pre>ansible-playbook -i inventory/democluster/hosts.yaml cluster.yml --become</pre><p>The installation may take some time to complete. Once the installation is successful, you will see a result like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZrJyMlaFCIGofegUuaW-zA.png" /></figure><h4><strong>Verifying the Cluster</strong></h4><p>After the Kubernetes cluster installation is complete, you can connect to the control-plane server and check the status of the nodes to verify the installation.</p><pre> #Connect K8s-control-plane node<br> ssh -p &#39;22&#39; &#39;demo@10.0.0.4’<br> <br> #Copy kubeconfig to user path<br> sudo mkdir -p $HOME/.kube<br> sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config<br> sudo chown $(id -u):$(id -g) $HOME/.kube/config<br> <br> #Get node status<br> kubectl get nodes</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*oUz4HBC-QvZuIMt3Uw1a6w.png" /></figure><p>It is not a good practice to run container applications on the Kubernetes master node. To ensure that container applications run only on worker nodes, you can use the following commands to add taints and labels to the Kubernetes nodes:</p><pre>kubectl taint nodes k8s-control-plane node-role.kubernetes.io/master:NoSchedule<br><br>kubectl label nodes k8s-workernode-01 kubernetes.io/role=worker<br><br>kubectl label nodes k8s-workernode-02 kubernetes.io/role=worker</pre><p>To sum up, Kubespray simplifies the process of creating Kubernetes clusters, making it accessible to a wider audience. Whether you’re a beginner exploring Kubernetes or a operator managing production-grade clusters, Kubespray provides a user-friendly and powerful solution for deploying Kubernetes with ease.</p><p><em>Thank you for reading my blog post! Do you have any additional tips or strategies for Kubernetes Cluster Management? I’m eager to hear your insights. </em><a href="https://twitter.com/uysal_alparslan"><em>Connect with me on Twitter!</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*sRhI5D8IHPMTABcU.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a29c58b13a2" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/guide-to-efficient-kubernetes-cluster-setup-with-kubespray-8a29c58b13a2">Guide to Efficient Kubernetes Cluster Setup with Kubespray</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Guide to Git Branching Strategies]]></title>
            <link>https://faun.pub/a-guide-to-git-branching-strategies-c7c22c4848d3?source=rss-37229d01f38------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7c22c4848d3</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[sdlc]]></category>
            <dc:creator><![CDATA[Alparslan Uysal]]></dc:creator>
            <pubDate>Wed, 04 Sep 2024 16:35:27 GMT</pubDate>
            <atom:updated>2024-09-04T16:35:27.004Z</atom:updated>
            <content:encoded><![CDATA[<p>Source control management is the practice of tracking and managing changes to code. It ensures efficient collaboration within teams or across teams, as well as versioning and managing the needs of the team using different management options such as Git, Tfvc, Svn, depending on their requirements for managing source code. Git, which has become increasingly popular in recent years, especially in open-source software development, plays a significant role and is widely preferred. When selecting a tool for source code management, we can consider the team’s experience, ease of use, and project requirements. In this blog post, we will focus on Git, an open-source tool with a distributed architecture. However, choosing the right source code management tool is just as important as software development principles because it plays a crucial role in how the team develops the software and the software’s lifecycle from the initial development stage to the customer delivery stage. Generally, there are two different principles associated with Git: Trunk-based development and Gitflow.</p><h4>Trunk-based Development</h4><p>In the trunk-based workflow, which is used as a principle for source control management, developers collaborate on a single long-lived branch (main), and the main branch should always be deployable. This principle focuses on continuously committing small changes to the trunk and aiming for quick integration and deployment of code to environments. The key feature of trunk-based development is enabling fast development and delivering completed work to the customer in the shortest possible time. Different strategies can be applied based on the team’s size, frequency of deployments, or the team’s level of experience.</p><p><strong>For smaller Teams:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*2UyCLcZKOwSyD_X7MZtdjw.png" /></figure><p>In this strategy, which enables fast development for small teams, developers work by making small commits to the trunk (main). When committing to the trunk, it is essential to ensure the health of the code being merged by performing pre-hook validations.</p><pre>git checkout main<br><br>git commit <br><br>git push origin main</pre><p>When the release is ready, a release branch is created from the trunk. After creating the release branch, no new features should be added to it, and bug fixes should be committed to the trunk instead.</p><pre>git checkout main<br><br>git checkout -b release/1.0.0</pre><p><strong>For scaled Teams:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RM9JKm7hhmhsL5DIWxiJ5w.png" /></figure><p>In this strategy that enables fast development for large teams, short-lived feature branches are created, and they are sent to the trunk through pull requests (PRs).</p><pre>git checkout main<br><br>git checkout -b feature/abc<br><br>git push origin feature/abc</pre><p>Developers create the feature branch from the trunk, and once their work is completed, they push it to the remote repository and open a pull request (PR).</p><pre>git checkout main<br><br>git merge feature/abc</pre><p>In a project involving large teams, it is crucial to protect the stability of the trunk through PR code reviews. This practice helps identify potential errors in advance and ensures that the trunk remains stable.</p><p>When all the necessary tasks for a release are completed in the trunk, a release branch is created by branching off from the trunk. After creating the release branch, bug fixes should be completed in the trunk, not in the release branch.</p><pre>git checkout main<br><br>git checkout -b release/1.0.0</pre><p>Trunk-based development is quite similar to the GitHub flow structure. The main difference lies in which branch deployments are made from. In the GitHub flow structure, deployments are always made from the main branch. In trunk-based development, however, deployments are made from release branches. So, is it really important from which branch deployments are made? And in which areas does it help us?</p><p>The answer to this question may vary depending on the needs of the teams. However, if a team has a high deployment frequency, such as deploying more than once or twice a day, planning and coordinating these releases can require communication, potentially extending the time required for immediate deployments.</p><h4>Gitflow</h4><p>Gitflow is one of the popular git branching strategies preferred by organizations. It enables effective code development for large teams and offers several advantages when developing an established product with a regular release cycle. One of its most significant advantages is enabling parallel development. With its branch structure, completed work is isolated from new development, ensuring that planned tasks are not disrupted. Developers move their development using feature branches over two primary branches, unlike trunk-based development. These primary branches are the “develop” and “release” branches.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iGXsHQ7VtqJyBz2c9P_jOw.png" /></figure><p>In trunk-based development, when developers work on a feature, they branch it of the main branch. However, in Gitflow, the base for feature development is always taken from the develop branch.</p><p>If you choose Gitflow as your branching model workflow, the first step would be to create a develop branch from the main branch and synchronize these two branches.</p><pre>git branch develop<br><br>git push -u origin develop</pre><p>Now, the develop branch is available for software teams to use, and when developers are working on a feature, they need to create a dedicated feature branch for that particular task. It is important to note that each feature should have its own separate branch.</p><pre>git checkout develop<br><br>git checkout -b feature/abc</pre><p>After developers complete their work in the feature branches, they push their changes to the central repository, and then the completed work is merged into the develop branch. It is important to merge the completed work into long-lived branches like develop through pull requests (PRs). This is because the develop branch is a shared base branch for everyone in the software team and should be as bug-free as possible.</p><p>Once all the necessary features for a release are merged into the develop branch, a release branch is created. When creating the release branch, the develop branch is used as the base. This approach allows for parallel release planning while the planned work for the release continues. After the release branch is created, no new features should be added to it. Only bug fixes observed during UAT (User Acceptance Testing) before deployment in the planned release should be merged into the release branch.</p><pre>git checkout develop<br><br>git checkout -b release/1.0.0</pre><p>When the release is ready for deployment, it is merged into the main branch and tagged with the release number. Additionally, after merging the release branch into the main branch, it should also be merged into the develop branch. This is done to ensure that bug fixes applied to the release branch do not impact newly opened features in development.</p><pre>git checkout main<br>git merge release/1.0.0<br><br><br>git checkout develop<br>git merge release/1.0.0</pre><p>In the Gitflow branching strategy, hotfix branches are used to resolve production issues. A hotfix branch is similar to release and feature branches but, unlike other branches, it is directly based on the main branch. Hotfix branches have their own unique workflow because they need to be addressed as quickly as possible to fix critical issues without disrupting other planned work.</p><p>To start a hotfix, developers create a branch directly from the main branch. After completing the necessary work, the hotfix branch is merged back into both the develop and main branches. This ensures that the fixes are applied to both the ongoing development work and the stable main branch.</p><pre>git checkout main<br>git checkout -b hotfix/xyz</pre><p>Exactly, merging the hotfix branch into the develop branch is necessary to prevent future planned work from being affected by any bugs or issues addressed in the hotfix. It ensures that the ongoing development work in the develop branch remains free from the hotfix-related problems and maintains the stability and integrity of the codebase.</p><pre>git checkout main<br>git merge hotfix/xyz<br><br>git checkout develop<br>git merge hotfix/xyz</pre><p>In summary, popular branching strategies such as Gitflow or trunk-based provide a foundation for software teams to work effectively. The choice of strategy is based on factors such as the team’s experience level, the number of developers in the team, and the need for rapid development. The selected strategy guides the team’s workflow. However, teams may change their working strategy based on future needs and determine the most suitable approach for themselves.</p><p><em>Thank you for reading my blog post! Do you have any additional tips or strategies for Git branching strategies? I’m eager to hear your insights. </em><a href="https://twitter.com/uysal_alparslan"><em>Connect with me on Twitter!</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Gkjsn5hiNu6gyQzP.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7c22c4848d3" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/a-guide-to-git-branching-strategies-c7c22c4848d3">A Guide to Git Branching Strategies</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Step-by-Step Guide to Jenkins Installation for CI/CD Success]]></title>
            <link>https://medium.com/cloudnewscast/a-step-by-step-guide-to-jenkins-installation-for-ci-cd-success-62e6f531ac5c?source=rss-37229d01f38------2</link>
            <guid isPermaLink="false">https://medium.com/p/62e6f531ac5c</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[jenkins]]></category>
            <dc:creator><![CDATA[Alparslan Uysal]]></dc:creator>
            <pubDate>Sun, 01 Sep 2024 10:26:10 GMT</pubDate>
            <atom:updated>2024-09-01T10:26:10.785Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*F70rqKig6JZfFmgpF-Pxlg.jpeg" /></figure><p>One of the main goals of DevOps culture is to automate everything as much as possible. By automating processes such as environment, application, authorization, security, quality, and testing, we establish a more agile organization. In the software lifecycle, we use tools that enable the automation of processes required to develop a feature and deliver it to the customer by deploying it to live environments. One of the first tools that come to mind when thinking of DevOps is build automation tools. We should choose one of the well-known tools in the market according to the organization’s needs. In this blog post, we will install Jenkins, a tool that is especially popular because it is open source and has abundant documentation and support resources.</p><p>Jenkins is the leading open source automation server, providing hundreds of plugins to support building, deploying, and automating any project. Before starting the installation of Jenkins, we need to consider why we will use Jenkins, the size of the teams that will use the system, the criticality of the applications, and so on. The most important decision to make during installation is whether we need a standalone or cluster setup. For example, if it will be used for non-critical tasks in a small organization and the number of build automations is low, a standalone installation may suffice. However, if it compiles critical applications, deploys to live environments, and the number of teams using it is large or will increase in the future, we must choose the cluster structure.</p><p>A standalone installation is simple; the Jenkins application is installed on a single server. The installed application runs as a single instance (master). The configuration files of the Jenkins application, build dates, job configurations are all on the same server, and build jobs run on this single server. The main advantage of a standalone installation is that management is simple, with everything observable on one server. However, if this server becomes inaccessible, no build automation will run, and the SDLC processes of critical applications will be disrupted. Also, scaling this setup is only possible vertically; as the teams using Jenkins increase, the memory, CPU, and disk capacity of the server must be increased to meet the growing load demand.</p><p>In a cluster installation, a Jenkins master (controller) and multiple agents are installed. The Jenkins controller does not run build jobs; instead, it schedules them for the agents to run. The agents, receiving the job notification, run the job and deploy it to the necessary environments. The main advantage of this structure is its ability to easily meet increasing demands on Jenkins and its easy scalability. Increasing demands are met by adding an additional agent to the cluster; post-installation, the master schedules the jobs it cannot handle to the newly added agent, balancing the loads. Another important advantage is that certain applications may need to be built on specific servers with certain frameworks or may need to run on a special server for security reasons. To meet these needs, a Jenkins agent can be installed on a specially selected server and included in the cluster. During job configuration, the job can be tagged to run only on this server.</p><h4>Jenkins Cluster Installation</h4><p>After configuring two different virtual machines, one as the controller and one as the slave, on your favorite cloud provider or your own server environment, we can start the installation. In this blog, for demonstration purposes, we will set up servers with one slave running the Ubuntu 20.04 operating system, and the necessary installations will be configured according to Ubuntu 20.04. However, you can add multiple slaves to the cluster using the same method according to your needs.</p><p>Java must be installed on the server for Jenkins to run. For each Jenkins server in the cluster, in our example one controller and one slave, you can install Java as follows.</p><pre>sudo apt update<br>sudo apt install -y openjdk-17-jre<br>java -version</pre><p>After completing the Java installation, you can proceed to the Jenkins installation. We can install Jenkins on the Jenkins controller (master) server by following these steps.</p><p>It is recommended to download the Jenkins installation from the project’s repository because the project repository always updates the LTS (Long-Term Support) version. You may find an outdated version in Ubuntu or different repositories.</p><p>To add the Jenkins repository to your Ubuntu system, you can run the following commands:</p><pre>curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \<br>  /usr/share/keyrings/jenkins-keyring.asc &gt; /dev/null<br><br><br>echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \<br>  https://pkg.jenkins.io/debian-stable binary/ | sudo tee \<br>  /etc/apt/sources.list.d/jenkins.list &gt; /dev/null</pre><p>After adding the repository to the system, we can update the system and install Jenkins.</p><pre>sudo apt-get update<br>sudo apt-get install -y jenkins</pre><p>After installing Jenkins, you can check the status of the service with the following command. The output should be similar to the image below.</p><pre>sudo systemctl status jenkins</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dEjmGkfOQpSFBgT0lpKzhQ.png" /></figure><p>When you install Jenkins by default as described above, it will run on port 8080. If the firewall is active on the server, you need to allow traffic on port 8080. To check if the firewall is active, you can run the following command:</p><pre>sudo ufw status</pre><p>If the firewall is not active, you can activate it and allow traffic on port 8080 with the following steps:</p><pre>sudo ufw allow 8080<br><br>sudo ufw enable</pre><p>To perform the initial configuration of Jenkins, we need to access the web interface. We need to enter the IP address of the Jenkins controller server and the port on which the application is running into the browser. The server must be accessible on port 8080. If you are using Azure, AWS, or Google Cloud, you need to allow this port from specific networks.</p><p>http://&lt;jenkins controller ip&gt;:&lt;port number&gt;</p><p>After entering the server and port information into the browser, a web page like the one below will appear. On this web page, to ensure that the installation is securely done by the administrator, a password located on the server is requested. You need to open this password with the cat command and enter it on the screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*hdwxs7LrwMKuPT2EZuPuPg.png" /></figure><p>Run the following command on the server where Jenkins is installed, then enter the output into the password field and click the Continue button.</p><pre>sudo cat /var/lib/jenkins/secrets/initialAdminPassword</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*CanpBrnGqK8npqatq-R5VQ.png" /></figure><p>On the next screen, you will be prompted to select which plugins you want to install for Jenkins. Jenkins has a rich ecosystem of plugins developed for almost every need. You can choose to automatically install plugins that the community finds useful, or you can list and install plugins tailored to your specific requirements. Additionally, after installation, you can install new plugins or remove existing ones at any time through the Jenkins interface. For demo purposes, we will choose the option “Install Suggested Plugins.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*dzrYjvjwrw7uK1vB2QxcDA.png" /></figure><p>On the next web page, we need to create the first admin user. You can create this user as you wish.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*ZlFOGoJJiddswHfoqx4w-g.png" /></figure><p>On the screen below, we are expected to specify the Jenkins root URL. We will log in to Jenkins with the URL we enter in this field, and as stated in the description, the BUILD_URL information that can be used in Jenkins’ email notification and build steps will be based on this root URL. The pre-filled value on the screen usually shows the server IP in the default installation. If you have a domain name for Jenkins, you can write it in this field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*A9iXU7uCknlJKNiXe5H3bg.png" /></figure><p>On the next web page, a screen appears informing you that Jenkins is ready for use, and by clicking the Start Using Jenkins button, you will be directed to the home page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*Ot9USnsbIcggNN93oBC_GA.png" /></figure><p>We have completed the Jenkins installation by completing the steps above, but it would be more beneficial and safer to install Jenkins in a cluster structure, not standalone. Build operations in Controller are not recommended by Jenkins, and in a distributed structure, we will add a slave to the cluster to run build jobs on slave servers.</p><p>To add a build slave to the cluster, we need to follow the steps below. You can add a build slave with a different OS type, but in this example we will include a server with the Ubuntu 20.04 operating system in the cluster.</p><p>We need to go to the Manage Jenkins page from the Jenkins main screen and then access the Nodes and Clouds page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0fZZoVurD3GEOTmPhmz1tg.png" /></figure><p>On the Nodes and Cloud page, we can view and configure the nodes in the cluster or add a new node. As you can see on the screen, the Built-in Node will appear in the list in a newly installed Jenkins. It is a server that we configure as a Build-in Node controller. To add a new node, we need to click on the New Node button at the top right of the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MEpPY4MPUW4dM3vEiQ29IA.png" /></figure><p>On the first page that opens, you can write the name we will give to the build node and select the Permanent Agent option, then click the Create button and go to the next page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5IEJmZpGRnAkTH1KQfw15A.png" /></figure><p>On this page where we will configure the node, we must enter some information, some are optional.</p><p>Number of executors: This field allows you to specify how many jobs can run concurrently on that node. By default, it is set to 1. You can adjust this value based on your system’s CPU capacity and workload requirements.</p><p>Remote root directory: The agent must have a folder on the server where it will be installed. You can choose a temporary location for this folder, such as tmp, but when the server reboots, the tools and source code you downloaded in the pipeline will be deleted. You can give a path on a permanent disk to benefit from the cache.</p><p>Labels: It provides a way to categorize and group build agents (nodes) based on specific characteristics or capabilities. This feature allows you to effectively manage and distribute build jobs across different types of nodes or agents in your Jenkins environment.</p><p>Launch method: To install an agent on a server in Jenkins, there are two different methods available. The first method is “Launch agents via SSH,” which involves Jenkins controller connecting to the target server using the provided credentials to automate the installation. It’s essential to ensure that Jenkins controller has access to the SSH port of the agent server.</p><p>The second method is “Launch agent by connecting it to the controller,” which is an inbound method. In this approach, Jenkins provides you with a JAR file and a command to run on the agent server. After manually executing this command on the server, the agent will join the Jenkins cluster.</p><p>We will use the ssh method in this installation, but you can choose the inbound method according to your needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6pfj7sX9pZ4W1KQjZtFr3w.png" /></figure><p>As you can see on the screen, after entering the IP address of the server where the agent will be installed, you need to provide a username for SSH connection. Jenkins controller will use this username to connect to the server and complete the agent installation. To add this user, you should click on the “Add” button in the Credentials section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h7PfSxWqhyUM1_FxDSaEUA.png" /></figure><p>There are multiple options available to connect to the server, such as SSH key, username, password, and more. In this example, we will proceed with a user defined on the server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s1lDP-DYyXDc2Mr0tR0pPg.png" /></figure><p>After the configuration work is completed, we can start the installation by clicking the save button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Jb9VToHEcEAOC7MoMLdfQ.png" /></figure><p>After clicking the “Save” button, you will be redirected to the Nodes page. On this page, once the newly installed agent has successfully joined the cluster, it will appear online and ready for use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cVoyM2bu1Ai1xFUNnrt9Gw.png" /></figure><p>If the agent encounters any issues while joining the cluster, you can view the details in the agent node’s log page. This log provides specific information about what went wrong during the connection or setup process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C9z6lppJYzm23mlEDjl_dw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nNjHwa-XIKbJsHJwROvXdw.png" /></figure><p>Once the agent installation is complete, you can define your build jobs in Jenkins using pipeline definitions.</p><p><em>Thank you for reading my blog post! Do you have any additional tips or strategies for Jenkins Installation? I’m eager to hear your insights. </em><a href="https://twitter.com/uysal_alparslan"><em>Connect with me on Twitter!</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62e6f531ac5c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudnewscast/a-step-by-step-guide-to-jenkins-installation-for-ci-cd-success-62e6f531ac5c">A Step-by-Step Guide to Jenkins Installation for CI/CD Success</a> was originally published in <a href="https://medium.com/cloudnewscast">CloudNewsCast</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>