<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Athreya Patel</title>
    <description>The latest articles on DEV Community by Athreya Patel (@athreyapatel).</description>
    <link>https://dev.to/athreyapatel</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F213488%2Fe099c51a-d489-4678-9f21-5b67dd6e31dc.jpg</url>
      <title>DEV Community: Athreya Patel</title>
      <link>https://dev.to/athreyapatel</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/athreyapatel"/>
    <language>en</language>
    <item>
      <title>Jenkins Tweaks for Beginners - Part 2</title>
      <dc:creator>Athreya Patel</dc:creator>
      <pubDate>Sat, 02 May 2020 16:09:26 +0000</pubDate>
      <link>https://dev.to/athreyapatel/jenkins-tweaks-for-beginners-part-2-3e04</link>
      <guid>https://dev.to/athreyapatel/jenkins-tweaks-for-beginners-part-2-3e04</guid>
      <description>&lt;p&gt;&lt;strong&gt;Jenkins&lt;/strong&gt; is an open source automation tool which made CI and CD super easier to implement. But for beginners, it would take loads of time to come up with a solution for a feature. It has limitations, but comes with a wide range of plugins which would add lots of features.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.athreyapatel.codes/awesome-features-in-jenkins-which-makes-it-interesting-for-beginners-part-1-3b4a1440e7b1"&gt;Here &lt;/a&gt; is my Part 1 which explains on some UI tweaks which can be added to Jenkins.&lt;/p&gt;

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

&lt;p&gt;As we are discussing about tweaks, All you need is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Basic Understanding on how to write pipelines in Jenkins.&lt;/li&gt;
&lt;li&gt;Basic Linux and Java skills to understand the working. &lt;/li&gt;
&lt;li&gt;Groovy for scripting&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setting up pipelines:
&lt;/h2&gt;

&lt;p&gt;In Jenkins pipeline can be defined in two types of syntax&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Declarative&lt;/li&gt;
&lt;li&gt;Scripted&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Declarative&lt;/strong&gt; approach helps us to to write and read Pipeline code easier. It provides support for various technologies like Docker and Kubernetes. I will be using this approach.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pipeline {
    agent any 
    stages {
        stage('First Stage') {
            steps {
                echo 'Hello world!' 
            }
        }
        stage('Second Stage') {
            steps {
                echo 'Hello Hello world!' 
            }
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Scripted&lt;/strong&gt; approach was the first implementation of Pipeline as Code and is imperative programming approach.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node {  
    stage('First Stage'') { 
        echo 'Hello world!' 
    }
    stage('Test') { 
        echo 'Hello Hello world!'
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Script Console
&lt;/h2&gt;

&lt;p&gt;The script console in Jenkins provides an environment to try out scripts which can be used in Jenkins without Script approval.  😆&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Don't ever reload the page without copying the script&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;You can find the script console by navigating to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;YOUR_IP:PORT/script
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;107.235.18.170:8080/script
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QZ0CmwBS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1588431551508/-Py06R2gK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QZ0CmwBS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1588431551508/-Py06R2gK.png" alt="Script Console"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding Parameters to Pipeline:
&lt;/h2&gt;

&lt;p&gt;Parameters in Jenkins can be used to define environment variables which can be accessed in the pipeline for performing certain tasks.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Go to your project &amp;gt; Configure &amp;gt; Checkbox "This project is parameterised"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--d5oDXOFR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1588432152364/y33MblDI9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--d5oDXOFR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1588432152364/y33MblDI9.png" alt="Adding Parameters"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Snippet Generator
&lt;/h2&gt;

&lt;p&gt;Snippet Generator will generate pipeline script which can be used inside the pipeline. It generates scripts for installed plugins. I have already explained in my last blog on how plugins can add features to Jenkins.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Go to your Project &amp;gt; Select Pipeline Syntax from the LeftPane &amp;gt; Snippet Generator&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Generate Scripts for Declarative Syntax
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Go to your Project &amp;gt; Select Pipeline Syntax from the LeftPane &amp;gt; Declarative Directive Generator&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;Lets conclude the above learnt steps from an example&lt;/p&gt;

&lt;h3&gt;
  
  
  Install Extended Choice Parameter
&lt;/h3&gt;

&lt;p&gt;Manage Jenkins &amp;gt; Manage Plugins &amp;gt; Search for " &lt;a href="https://plugins.jenkins.io/extended-choice-parameter/"&gt;Extended Choice Parameter&lt;/a&gt; " &amp;gt; Install without restart&lt;/p&gt;

&lt;p&gt;Extended Choice Parameter is similar to Choice Parameter where user is provided with choice, but extended choice provides enhanced features by providing a way to use Groovy Script which can be used to return array of values.&lt;/p&gt;

&lt;h4&gt;
  
  
  Create a pipeline
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;New Item &amp;gt; Select &lt;code&gt;Pipeline&lt;/code&gt; &amp;gt; Enter an item name &amp;gt; OK&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ILmpOVCO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1588433592890/0EIa2Xx6u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ILmpOVCO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1588433592890/0EIa2Xx6u.png" alt="Creating a Pipeline"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lets copy the pipeline script provided at top in declarative approach to &lt;code&gt;Pipeline script&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Generating extended choice parameter from Declarative Generator
&lt;/h4&gt;

&lt;p&gt;In the Declarative Generator &amp;gt;  From the dropdown select &lt;code&gt;parameters: Parameters&lt;/code&gt; &amp;gt; Add &amp;gt; extendedChoice: Extended Choice Parameter&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VjjZUrhX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1588434238489/vGU6-iaTn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VjjZUrhX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1588434238489/vGU6-iaTn.png" alt="Extended Choice Parameter"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Verify the working of script in Script Console
&lt;/h4&gt;

&lt;p&gt;In another tab, verify the working of the script&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--px1f8chN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1588434345737/WbfCSf37a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--px1f8chN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1588434345737/WbfCSf37a.png" alt="Script Console"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Generate Declarative Directive from Declarative Generator and Copy&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here is the final pipeline which I can use in the Pipeline Script of the project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pipeline {
    agent any 
    parameters {
      extendedChoice bindings: '', description: 'this is for the demo example', groovyClasspath: '', 
        groovyScript: '''def example = "1"

      if(example == "1") {
           return ["1st","2nd","3rd"]
      }''', multiSelectDelimiter: ',', name: 'example', quoteValue: false, saveJSONParameterToFile: false, type: 'PT_SINGLE_SELECT', visibleItemCount: 4
    }

    stages {
        stage('First Stage') {
            steps {
                echo 'Hello world!' 
            }
        }
        stage('Second Stage') {
            steps {
                echo 'Hello Hello world!' 
            }
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now build the Project using Build Now&lt;/p&gt;

&lt;p&gt;After the first build, the &lt;code&gt;Build with Parameters&lt;/code&gt;  replaces &lt;code&gt;Build Now&lt;/code&gt;&lt;br&gt;
Click on &lt;strong&gt;Build with Parameters&lt;/strong&gt; to Select to select the parameter and &lt;strong&gt;Build&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These tweaks can make Jenkins awesome for CICD pipelines and is loved by many ❤️. &lt;/p&gt;

&lt;p&gt;Thanks!!&lt;/p&gt;

</description>
      <category>devops</category>
      <category>cloud</category>
      <category>jenkins</category>
      <category>devlive</category>
    </item>
    <item>
      <title>Awesome Features in Jenkins which makes it interesting for beginners — Part 1</title>
      <dc:creator>Athreya Patel</dc:creator>
      <pubDate>Mon, 27 Apr 2020 20:03:35 +0000</pubDate>
      <link>https://dev.to/athreyapatel/awesome-features-in-jenkins-which-makes-it-interesting-for-beginners-part-1-4365</link>
      <guid>https://dev.to/athreyapatel/awesome-features-in-jenkins-which-makes-it-interesting-for-beginners-part-1-4365</guid>
      <description>&lt;p&gt;Now, your team wants a automated solution for Continuous Integration and Continuous Deployment. You find &lt;strong&gt;Jenkins&lt;/strong&gt; is one of the most &lt;strong&gt;popular&lt;/strong&gt; tool and start with it.&lt;/p&gt;

&lt;p&gt;Eventually you find Jenkins boring with the same interface and user experience. &lt;strong&gt;Follow these tips to make your Jenkins interesting!!&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Lets start with UI
&lt;/h2&gt;

&lt;h2&gt;
  
  
  1. BlueOcean Plugin
&lt;/h2&gt;

&lt;p&gt;In Jenkins, whenever we need to add some features, we do it by installing plugins. These plugins are available in Manage Jenkins &amp;gt; Manage Plugins &amp;gt; Available section.&lt;/p&gt;

&lt;p&gt;Search for &lt;a href="https://plugins.jenkins.io/blueocean/"&gt;Blue Ocean&lt;/a&gt; &amp;gt; Select Blue Ocean and checkbox it. Then click on “Install without restart”&lt;/p&gt;

&lt;p&gt;Wait for it to install Blue Ocean with its dependencies.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IB1JCSBt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1587904696765/g6eGp7cKQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IB1JCSBt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1587904696765/g6eGp7cKQ.png" alt="Annotation 2020-04-26 172109.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you have “Open Blue Ocean” option. Click on it. Now you have a whole new different UI and you notice it is a Single Page Application built with React. Selecting the pipeline gives you the builds run.&lt;/p&gt;

&lt;p&gt;Advantage over Jenkins UI is&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; It gives different UI and UX.&lt;/li&gt;
&lt;li&gt; It provides better representation of pipeline stages. Consider the pipeline has stages to be skipped for certain builds. This provides the better representation which is the process which is undergone in that specific build.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NvVydbBm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1587904741876/NmUxr7Ij6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NvVydbBm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1587904741876/NmUxr7Ij6.png" alt="1_8DJ0oewT_qwDDoAyWo_ncw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Adding CSS for the UI
&lt;/h2&gt;

&lt;p&gt;Now, for some reason you still want to use Jenkins without Blue Ocean. You can use it better UI by tweaking some CSS.&lt;/p&gt;

&lt;p&gt;We can add CSS to the already existing traditional Jenkins UI with a plugin called &lt;a href="https://plugins.jenkins.io/simple-theme-plugin/"&gt;Simple Theme&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Lets install it from Manage Jenkins &amp;gt; Manage Plugins &amp;gt; Search for Simple Theme &amp;gt; Install without restart&lt;/p&gt;

&lt;p&gt;Then Manage Jenkins &amp;gt; Configure System &amp;gt; Go to “Themes” section &amp;gt; Click on Add Button&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BPnySmQu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1587904770989/h71qih5zI.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BPnySmQu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1587904770989/h71qih5zI.png" alt="1_Y3tVB225uddQzLR494DMiA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Search for Jenkins Themes in Google to find the CSS themes &amp;gt; Select the one based on your taste &amp;gt; Add the URL&lt;/p&gt;

&lt;p&gt;I personally prefer &lt;a href="https://tobix.github.io/jenkins-neo2-theme/"&gt;&lt;strong&gt;Neo2 Theme&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I have the link which has the css file. Apply &amp;amp; Save..&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jlQHkYqs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1587904786811/Q_OzOmq8M.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jlQHkYqs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1587904786811/Q_OzOmq8M.png" alt="Annotation 2020-04-26 17210.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;_We are done with some UI tweaks! Will go through other tweaks in the second part.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Thats it for the first part!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Will be continuing with some tweaks which we can do Jenkins in the next Part.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Stay tuned!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Any inputs in the blogposts are welcome&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Thanks&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;You can my follow blogs at&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://blog.athreyapatel.codes/"&gt;&lt;strong&gt;&lt;em&gt;https://blog.athreyapatel.codes/&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>jenkins</category>
      <category>uiweekly</category>
    </item>
  </channel>
</rss>
