groovy

41 posts

These 10 New Features Make Groovy 4.0 AWESOME!

Sealed types, switch expressions, and record types. Here are just a few new features introduced in the latest Groovy 4.0 release. In this video, I want to show you ten things that make Groovy 4.0 amazing. And to keep this video short, we’re not going to dive deep into each of them. Instead, I intend to give you a quick overview of the new features.

How to generate a random password in Groovy?

Sometimes you need to generate a random password (or just random string of any kind.) Today I will show you how to do it with a single line of code in Groovy 3 (or newer.)

Groovy Ecosystem Usage Report (2020)

What is the most popular Groovy library, framework, or a tool? I surveyed 308 Groovy community members, and here are the results.

How to merge two maps in Groovy?

One of the most popular map-related operation in any programming language is merging two (or more) maps. In this short blog post, I explain how to do it in the Groovy programming language, starting from the simplest + operation, up to more advanced use cases of merging nested maps and using runtime metaprogramming to add a merge method to the Map interface. Enjoy reading and learning!

How to time out Jenkins Pipeline stage and keep the pipeline running?

The declarative Jenkins Pipeline allows us to define timeout either at the pipeline level or the specific stage. This feature prevents Jenkins’s job from getting stuck. However, in some cases, we want to accept that one stage may timeout, but we want to keep the remaining stages running.

Groovy dynamic Maps, generic type erasure, and raw types - an interesting use case to learn from

Dynamic type inference in Groovy might be tricky. Add generic type erasure to it, and you can find yourself in trouble. In this blog post, I would like to show you such use case and explain what happens under the hood. Enjoy reading!

Groovy 3 @NullCheck annotation - less code and less NPE

Groovy 3 helps you write less, but more secure code. Today I want to show you one of the features added in the latest release - @NullCheck annotation.

Groovy 3 String GDK improvements - takeRight, takeBetween, and a few others

Groovy 3 was released a few days ago[1], and it introduced a lot of important new features to the language. Today I want to show you a few useful improvements in the GDK. We will take a closer look into methods like takeRight, takeAfter, takeBetween, and a few others that were added to the java.lang.String class.

Jenkins Scripted Pipeline vs. Declarative Pipeline - the 4 practical differences

If you read this blog post, there is a high chance you’re looking for information about practical differences between scripted and declarative pipeline, correct? You couldn’t find a better place then. I’m going to show you the four most practical differences between those two. Stay with me for a few minutes and enjoy the ride!

Three Groovy String methods that will make your life Groovier!

Groovy String API offers many useful methods to make working with strings much more pleasant. Today I would like to show you three, not so very popular, yet convenient methods. Let’s jump straight into it!

Quicksort in Groovy - can it be as fast as implemented in Java?

I started reading "Cracking the Coding Interview, 6th Edition" book recently and it inspired me to experiment a bit. It’s been a while since I implemented the quicksort algorithm the last time, and I did that in Haskell. I remember some old and imperative implementations in Java, but I never tried to implement it in Groovy. Let’s give it a try!

Building Java and Maven docker images using parallelized Jenkins Pipeline and SDKMAN!

In the last article, I have shown you how you can build a docker image for Jenkins Pipeline using SDKMAN! command-line tool. Today I will show you how you can build multiple different docker images using parallelized Jenkins Pipeline.