Groovy is a general purpose language that runs on the top of the JVM, the Java Virtual Machine that seems to allow developers to be a lot more productive than using Java.

My primary reason for looking into it is that it is the language used for the Jenkins Pipelines.

Oh and you can also grab my Groovy book.

Articles

Other resources

examples/groovy/enum_planets.groovy

enum planets {
   Mercury,
   Venus,
   Earth,
   Mars,
   Jupiter,
   Saturn,
   Uranus,
   Neptune
}

println("hi")

println(planets)
println(planets.Earth)

Elapsed time

examples/groovy/elapsed_time.groovy

import groovy.time.TimeCategory
import groovy.time.TimeDuration

def start = new Date()
println(start)
print("Press any key ...")
def name = System.in.newReader().readLine()
def stop = new Date()
println(stop)
diff = stop - start
println(diff)


TimeDuration td = TimeCategory.minus( stop, start )
println td


Groovy regex

1) Interpolation can be used 2) matcher.matches vs being null ? 3) \b to mark end of word

def exp = 'line'

def matcher = (text =~ /\b$exp\b/)
println("hi")
if (matcher) {
    println("match")
}

groovy time duration - elapsed time

import groovy.time.TimeDuration

tdx = new TimeDuration(0, 0 , 0, 2000)
println(tdx)

http://docs.groovy-lang.org/2.4.9/html/gapi/groovy/time/TimeDuration.html

duration:

println(currentBuild.getClass()) //  class org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper  https://javadoc.jenkins.io/plugin/workflow-support/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper.html
println("duration: ${currentBuild.durationString}") // duration: 0.35 sec and counting
println(currentBuild.getDuration()) //  397   (miliseconds)
println(currentBuild.getDurationString()) // 0.4 sec and counting

https://stackoverflow.com/questions/51788139/how-to-get-jenkins-build-job-duration