Advanced Jenkins

Scaling Jenkins usage across a growing enterprise, without affecting the security or stability of its software development lifecycle (SDLC) is challenging, particularly for highly regulated industries. In this Refcard, we outline core practices for setting up efficient, secure Jenkins pipelines.

How to Render Jenkins Build Parameters Dynamically

While working with Jenkins jobs (whether they're declarative or freestyle), we often need to pass some parameters to the code being executed when triggering the job. Jenkins supports this use-case by means of parameters that you can declare and use as Groovy variables in your Jenkins job. However, often you are not aware of all the parameters in the beginning, or sometimes you want to render the parameters dynamically based on the value selected in any other parameter. 

Given the declarative nature of Jenkins jobs, we cannot achieve the use-case with the native Jenkins parameters available. Here comes the Active Choices parameter plugin to the rescue, which can help us render parameter values dynamically.

Migrating Jenkins Freestyle Job to Multibranch Pipeline

Anyone who recently started working on Jenkins, or started within the past few years, would by default go with creating pipelines for their CI/CD workflow. There is a parallel world, people who have been using Jenkins from its inception, who didn't get on a foot race with new Jenkins features and stayed very loyal to 'Freestyle jobs.' Don't get me wrong, Freestyle job does the work, can be efficient and a simple solution if you have a 1-dimensional branching structure in your source control. In this post, I would discuss why switching to Multibranch Pipeline was needed for one of our enterprise customers and how it has made their life easy.

Freestyle vs. Pipeline Jobs

Freestyle jobs are suitable for simple CI/CD workflow accompanied by a simple branching strategy. If you have multiple stages in your CI/CD design, then it's not the right fit. That's where the Pipeline enters.

Lesson Learned on Groovy

Though I have worked on Java for more than a decade, I have not had a chance to work on Groovy. While working for API Integration into Jenkins CI/CD pipeline, I extensively used Groovy to invoke REST API, validate the user input parameters, and business logic for that. After that, I found that Groovy is a fascinating program language for Java developers.

Why Is Groovy Easy for Java Developers?

It allows to use the Java syntax liberally and tries to be as natural as possible for Java developers. It is an object-oriented dynamic programming language for Java virtual machine (JVM) and can be integrated smoothly with any Java Program. The groovy syntax is lucid, familiar, and direct that makes to develop projects faster and easier. It demands a shorter learning curve for Java Developer to develop, test, and integrate to make production-ready code in a short span.

Jenkins CI/CD With Git Secrets

Connect all your Git secrets to the Jenkins pipeline.

It's a common practice to encrypt the secrets/credentials we use in our code and then save it in some secure place. We have a number of options to achieve this, with tools like Vault, Git-crypt, and more. However, git-secret is one simple awesome tool that we can use to store our secrets in our Git repo. Git secret uses gpg for encryption and decryption of secrets. 

Here's how git-secret works. Go to the folder in your repo in which you have files to encrypt. Then, run git init && git secret init. This would initialize your .gitsecret folder. Then you run git secret tell $email , and if you want other users to decrypt the secrets file you have to import their gpg public key and again run git secret tell $otheruseremailid . Now you can run git secret add $secretfilename and git secret hide,which creates $yoursecretfile.secret file, which is an encrypted secret file.

Cleaning MuleSoft CloudHub Resources: A DevOps Approach

Introduction

MuleSoft provides excellent business agility to companies by connecting applications, data, and devices, both on-premises and in the cloud with an API-led approach. Together, APIs and DevOps deliver greater business value than what they can deliver individually.

DevOps is the combination of cultural philosophies, practices, and tools that increases an organization's ability to deliver applications and services at high velocity: evolving and improving products over the time.