How to run groovy script in Jenkins

FoxuTech
2 min readJan 21, 2019

--

After setup the master-slave and own private docker registry(cloud), now we would like to discuss about how to run the groovy script in Jenkins. Before we start, lets know some information about groovy.

What is a Groovy Script?

Apache Groovy is an Object-oriented programming language used for Java platform. This dynamic language has many features which are like Python, Ruby. It can be used as a scripting language for the Java platform.

It is almost like a super version of Java which offers Java’s enterprise capabilities. It also offers many productivity features like DSL support, closures, and dynamic typing. Unlike some other languages, it is designed as a companion, not a replacement for Java.

Groovy source code gets compiled in Java Bytecode, so it can run on any platform if JRE is installed on that operating system. Groovy also performs a lot of tasks behind the scene that makes it more agile and dynamic.

Why Groovy?

Here, are major reasons why you should use Groovy-

  • Groovy is an agile and dynamic language
  • Seamlessly integration with all existing Java objects and libraries
  • Feels easy and natural to Java developers
  • More concise and meaningful code compares to Java
  • You can use it as much or as little as you like with Java apps

Features of Groovy

  • List, map, range, regular expression literals
  • Multimethod and metaprogramming
  • Groovy classes and scripts are usually stored in .groovy files
  • Scripts contain Groovy statements without any class declaration.
  • Scripts can also contain method definitions outside of class definitions.
  • It can be compiled and fully integrated with traditional Java application.
  • Language level support for maps, lists, regular expressions
  • Supports closures, dynamic typing, metaobject protocol
  • Support for static and dynamic typing & operator overloading
  • Literal declaration for lists (arrays), maps, ranges, and regular expressions

Cons of using Groovy

continue on: https://foxutech.com/how-to-run-groovy-script-in-jenkins/

--

--

FoxuTech
FoxuTech

Written by FoxuTech

Discuss about #Linux, #DevOps, #Docker, #kubernetes, #HowTo’s, #cloud & IT technologies like #argocd #crossplane #azure https://foxutech.com/

No responses yet