Skip to content

2020

Use Reflection in Jenkins Pipeline

Jenkins Pipeline's class loading is different from the normal Java class loading. It has its own designed class loading within the plugins.

Here is the official introduction dependencies-and-class-loading.

Briefly, if we want to use reflection to dynamic load class defined in pipeline, we need to use Thread.currentThread().getContextClassLoader().

Java
Class<?> cls = Class.forName(className, true, Thread.currentThread().getContextClassLoader())
return cls.getDeclaredConstructors()[0].newInstance()

Resync MySQL Replacation DB

The Problem

We have a primary MySQL database and a replication, we plan to migrate them to another widget, so, IT cloned both of them in the new widget, and new two VMs are up. But the new replication database uses its default setting and sync from the old primary database, cause the new replication has diverged from the new primary.

The Requirement

Let the new replication to sync with the new primary to do validation test.

Solution