Monday, December 31, 2012

Jenkins enhancements without plugins

Jenkins is a popular open source continuous integration server. I use it heavily. Jenkins is super extensible CI server with huge plugins repository.
But I must admit that there are a lot of cases when all these Jenkins plugin's "zoo" doesn't help. What does it mean?:
  • we need a tons of plugin to solve some non-trivial problem,
  • too many plugins dependencies which must be properly managed
  • some available plugins partially provide required functionality
  • some plugins provide required functionality but contain bugs
  • or it might be impossible to find necessary plugin, and task have to be done ASAP
Based on these cases mentioned above we have at least two solutions:
  1. Implement own plugin which will provide all required functionality. It will take some time and slowdown the overall progress for this particular business task
  2. Use some Jenkins extra facilities which gives us a chance for Jenkins automation without plugin writing
I'm a real fun od 2d solution (at least as a prototyping phase or quick-and-dirty solution right-now-right-away).

So, what's the magic? Jenkins has two nice plugins (of cause there are much more similar plugin, but these two are the best for quick start) which give us a possibility to write Groovy scripts for build and post-build phases:
  • Groovy scripts have access to whole Jenkins infrastructure (Jenkins packages) and can invoke functionality of third-party plugins installed in this Jenkins instance
  • It's very easy to prototype your ideas and validate automation approaches
  • It gives us very quick business results
  • Groovy scripts can automate really amazing and non-trivial tasks
  • at the end these Groovy scripts are not easy for automated testing
  • version managements for these scripts involve additional work (implement simple import/export tool for job configuration)
  • these Groovy scripts can have dependency on some third-party plugins and these dependency must me somehow managed as well
  • testing and debugging are really painful activities, because it involve too many interactions with Jenkins UI, etc. (yes, it can be somehow improved via extending both Groovy plugins, but it's extra work)

Wednesday, December 12, 2012

Groovy or JRuby for Java developer

Today I've decided to share my own perception about the subject "Groovy vs JRuby" for Java developers.
When we are talking about any dynamic/scripting language like Ruby, Python, Groovy, etc. we are talking about quick development feedback (e.g. run - fix - run) no compilation, no packaging.
I must admit that mentioned above languages cover the same tasks' domain with own pros&cons. Now, we should differentiate pragmatic and ecstatic sides for each of them.

When we are talking about programming language we should clearly understand the difference between:
  1. language (as syntax and semantic soup) - ecstatic side
  2. language's ecosystem (community, tools, libraries, etc.) - pragmatic side
Let's discuss item (1). I think that learning a new programming language expand developer's mind. If we know many programming languages it helps us pick up any new language very quickly. I.e. to be pragmatic programmers we should learn many languages, dead simple.
In my opinion Ruby has much "nicer" syntax and language features in comparison to Groovy. Ruby meta model is very flexible that's why it has so many beatify frameworks and libraries (Rails, Cucumber, Rspec, etc.). But …

But Ruby ecosystem is totally different from Java/Groovy world. And it's really noticible when we are trying to mix Ruby and Java in the same project.
Mixing JRuby and Java isn't a difficult task. But using Java API in Ruby code doesn't looks natural. And developing in mixed Java/Ruby environment isn't very comfortable:
  • we have two package types: JARs and gems
  • library versioning and dependency management is different
  • Ruby/JRuby still has some cross-plafrom issues, especially on Windows (i.e. many Ruby gems do not support Windows and they must be fixed to support it, very annoying)
  • it might be difficult to convince teammates to use Ruby on Java project 
I thought that Groovy isn't a (J)Ruby competitor until I've tried to automate some simple tasks in Groovy. I've got seamless integration with Java. It's really transparent and comfortable coding tool for Java developer. I have no mess with gems (Groovy uses JARs). And the Java ecosystem stays the same. Groovy has the similar dynamic power as Ruby. Yes, in some cases this "sugar" isn't so sweet as in Ruby. But, Groovy is really pragmatic choice for Java developer.

Conclusion: Ruby language is beautiful and sexy language, no doubts. But, we need a time to master Ruby ecosystem, deployment issues and tools philosophy. Also, JRuby/Java integration doesn't looks to me so pragmatic as Groovy/Java. It means investment in Ruby might be expensive.
I will recommend to learn Ruby just to open another community for yourself (if you are Java developer), it should be as self-education task, no more.