If you are thinking about migrating from a Jenkinsfile to GitHub Actions YAML at work, of course there is a GitHub Actions Importer tool and there are documents and courses available for the migration process from Jenkinsfile to GitHub Actions YAML.
But what if the Jenkinsfile written in your company is fully customised? In that case, the importer cannot do this as an automated function. So that’s where OpenRewrite comes in.
What is OpenRewrite?
OpenRewrite is a Java refactoring framework where you write the changes you want to do in your codebase, or the migration process, programmatically by writing code. In OpenRewrite terms this is called a Recipe. Recipes are written in Java, or now currently there is also a JavaScript capability to write a recipe. You define what you want to do programmatically in code, define it in a rewrite.yml file, then run the recipes to make the changes you want.
Why ScanningRecipe?
To migrate from a fully customised Jenkinsfile to GitHub Actions YAML, what we need is something that will produce another file format — and that's where ScanningRecipe comes in.
https://docs.openrewrite.org/concepts-and-explanations/recipes#scanning-recipes
Write on Medium
What it does: you write a recipe using OpenRewrite, store extracted values in an accumulator, and the recipe uses that accumulated data to generate the GitHub Actions YAML output.
The flow looks like this:
Scanner reads the Jenkinsfile LST and extracts key-value pairs from the Jenkinsfile
Accumulator stores the extracted values grouped by type — env variables, step conditions, and step behaviours
Generate takes the accumulated data and produces .github/workflows/.yml
More Details
For more details on what is happening under the hood, clone the source code and try reading the code:
