Jenkins Pipeline Groovy Script – Part 1: Creating Gitlab Group

In this article, I am discussing a simple groovy functionality along with Jenkinsfile pipeline script on how to automatically create a new GitLab group or subgroup under the parent group.  In DevOps Continuous Integration(CI) and Continuous Delivery(CD), managing projects in git level is very much important and useful for version control.  These projects are organized under a specific groups to have a disciplined structure in order to handle the application deployment well via DevOps.

What Is Jenkins Groovy?

Groovy is  an object-oriented programming language like Java and has Domain Specific Language(DSL) features. Jenkins provides pipeline capabilities along with groovy DSL features for Continuous Integration(CI). So how to use Jenkins pipeline groovy script, use load keyword in Jenkinsfile to create constructor for groovy class. Using constructor or class object of that Groovy class, functions can be inherited and values are returned. In order to use Jenkins Pipeling Groovy script, in Jenkins CI server Pipeline Groovy Plugin should be installed as prerequisite.

Concatenate Strings in Groovy

1. Introduction

Groovy has two ways of instantiating strings. One is plain java.lang.String and the second is  groovy.lang.GString.

Plain string is represented with a single or double quote. However, the single quote doesn't support interpolation. Interpolation is supported only with a double quote, and when it is present, it becomes  GString. In this article, we will see the different types of string representations in Groovy and how to concatenate them.