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.

Why Camel K?

1. Dev Mode

 To run a camel spring boot or camel main application in Kubernetes, it requires a developer to build the docker or s2i images, create Kubernetes resources and then apply the resources to a running cluster which is very time-consuming. Camel K solves this problem and saves development time with the dev mode. Simply adding a --dev flag while running code allows the developer to deploy instantly to Kubernetes and also make any changes to the running pod whenever the source file is updated.

2. Dependency Resolution

 We know that camel supports multiple DSL such as Java or Groovy and Camel K supports it as well. What is new in Camel K is that the automatic dependencies management feature. The developer need not worry about packaging a deployable artifact or the maven or Gradle dependencies of various components. It automatically resolves the necessary dependencies from a source file during deployment. And also only one source file is enough to run integration in a pod.

Optimizing Code in a World That Doesn’t Want to Optimize

Premature optimization is the root of all evil.

It is a common saying among developers. It makes sense. Optimizing prematurely can mean redoing work down the line, and time is the developer’s most finite resource. It can mean spending that precious time optimizing for scenarios that do not yet exist for a product’s users. It can mean writing code that is harder to understand with unclear performance gains.

While participating with the WordPress theme review team about a year ago, I came across that nugget of advice once again. Premature optimization is the root of all evil. The reply was to a theme author who was looking to decrease the number and weight of scripts their theme needed to load. On one hand, the theme author could load a 1.29 kb script with no dependencies to get the job done. The other option was to use the jQuery-dependent script included in core WordPress for a total of 105 kb because “most” WordPress sites are loading jQuery anyway.

For me, the answer was simple. Use the smaller script unless the core script was already loaded on the front end. I did not think of it in terms of premature optimization. I thought of it as plain old, run-of-the-mill, everyday optimization.

Developers should not confuse premature optimization with the concept of making smart design decisions early in the process. Nor should they wait until the final stage of development to start optimizing, a time when the focus is on getting a product out to end-users. That is a sign of a poor product design process.

Over the past year, that conversation stuck with me. It helped me become more cognizant of a terrifying trend, not just in the WordPress developer community, but with web development in general. Far too often, developers are so far removed from normal users and the technology those users rely on that optimization is little more than an afterthought. Instead, it should always be at the forefront of any developer’s mind.

The overreliance on this misused quote has helped push the trend of measuring page weight in megabytes instead of kilobytes. It is too often used as a catchall justification for not doing any optimization in the development phase while making up for it with file compression and caching in production.

Part of writing quality code is optimizing that code during every stage of the development process. It is about making hard decisions to cut unnecessary things as the software comes together. Caching should be a last resort after everything else has been cleaned up.

Premature optimization is more about attempting to optimize when there are no clear gains or working on micro-optimizations that alter the software’s design for little-to-no benefit. It does not mean overlooking obvious performance boosts during development.

Not Everyone is on Gigabit Internet

Most developers I know are on super-fast internet connections, often with 1 Gbps download speeds and unlimited data. In that situation, it is easy to forget that large chunks of the world are still on slow connections with data caps.

Some may even associate slow connections with third-world countries where millions of people are on 2G cell phone technology. However, there are large swaths of the United States and other developed countries that have no direct cable or DSL lines, which are commonly available in cities and suburbs.

This disconnect is directly evident when other developers have initiated chats with me. In the past couple of years, it has been increasingly common for them to ask for a video chat. It is not even questioned whether such a thing is possible (video chats are unreliable at best for me). The ability to video chat at any time is taken for granted.

There are two internet service options in the area that I live in: satellite or dial-up. Even the local telephone company refuses to offer DSL in this area because of infrastructural costs with decades-old phone lines. Because of the prohibitive costs of satellite internet access, which typically comes with data limits, many are stuck with dial-up. Cell phone companies are changing the game to a degree, assuming service is reliable, but there are downfalls with going that route, which can include data or hotspot limitations.

For such a technologically-advanced country, many of its people are barely catching up to where others were a decade ago.

While I am fortunate enough to choose where I live and have nothing holding me back from moving, most do not have that option. They are stuck with the best they can afford. Even in rural areas, the internet is an inescapable part of daily life, and developers are not making it easy for these people.

While this is anecdotal, it is the stark reality of rural life in pockets of the US.

The upside of living in the backwoods of Alabama is that it has changed my perspective as a developer. It has meant that I needed to question every code decision for every plugin and theme I built. With data caps, I needed to make sure that I was not using too many resources.

More than anything, having a data cap changed how I used the internet. I now run an ad-blocker. I have an extension to kill videos from auto-loading. I disable JavaScript on heavy sites that I need to use. Some sites seem interesting, but I never return to them because they are resource hogs.

When you live in a place where every byte matters, you tend to avoid wasting them.

While not always successful, since my transition to small-town life, I have attempted to build applications in a way that served people who are not privileged enough to have blazing-fast internet access.

Pointing this out is about making sure developers are aware that optimization matters. It matters at every stage of the development process. It matters because these people with slow connections and data caps also need to buy products, use services, read content, and do all the other things that people do on the web.

If you are a developer who is thinking about adding that slider, swiping mechanism for mobile, or some other slick gadget, think about those of who must wait for that feature to load. Check that its dependencies are not loading too many extra resources. Do some research to see if you can locate a lighter-weight implementation. But, first, ask yourself if it is necessary.

The themes and plugins that WordPress developers build should never be the bottleneck for a website. We can do better.

Simplify Your Script Build With Gradle

Learn more about how to simplify your script build with Gradle

Gradle is an open-source build automation system that builds upon the concepts of Apache Ant and Apache Maven, and introduces a Groovy-based, domain-specific language (DSL), instead of the XML form used by Apache Maven to declare the project configuration. This post will cover how easy it is to use this tool, and how to migrate your Maven project to Gradle to run it on Platform.sh.

You may also like:  Make or Break Your Code With Gradle

Gradle is an excellent build tool with which we can automate Java applications using a clean DSL. But it’s essential to mention that Maven is still a valid and mature tool, and Gradle doesn’t deprecate Maven. There are several tutorials where both devices are compared, and you can see several companies going back and forth between Maven and Gradle. The answer to which one is the better tool is still uncertain. What matters is that at Platform.sh, you can choose both to move your Java application to the cloud.

Beginner’s Guide to Building an Online Retail Web Shop Workshop (Guided Rules)

With the release of Red Hat Decision Manager 7.3, I've started updating my free online workshop, a beginners guide to building an online retail web shop.

The previous article covered creating a domain-specific language or DSL for your online retail web shop.. This update is the for the fifth lab in this workshop, with more to follow. Learn how to create guided rules with Red Hat Decision Manager.