Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jenkinsfile Recipes? #12

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Jenkinsfile Recipes? #12

wants to merge 1 commit into from

Conversation

sghill
Copy link
Collaborator

@sghill sghill commented Aug 15, 2023

What's changed?

Added a few examples (as ignored tests) that new recipes may be able to refactor.

What's your motivation?

Exploring ways to be more specific in refactoring Jenkinsfile.
The Jenkins project recently announced the ability to test on JDK 21, but it requires a change to the project's Jenkinsfile.
Since Java is changing faster than ever before, it'd be great to automate this.
An example is in jenkinsci/commons-text-api-plugin#41.

Anything in particular you'd like reviewers to focus on?

What are the steps involved in parsing a Jenkinsfile as groovy?

This is a bit different than regular groovy in that a shared library defining possible functions is automatically imported by the Jenkins controller. Jenkins admins can define what shared libraries are imported on each controller, and whether or not it's implicit, so it can be very difficult to discover which functions are available on a given controller.

The definition of buildPlugin(), which I focus on here, is available in OSS.

Have you considered any alternatives or workarounds?

The current recipe to modernize a Jenkinsfile does text replacement. It works, but it's very opinionated. Open to other alternatives.

@timtebeek timtebeek added the question Further information is requested label Aug 15, 2023
@timtebeek
Copy link
Collaborator

As a bit of an update, the Groovy parser now also supports files that start with Jenkinsfile. The Groovy parser has also been added to the rewrite-maven-plugin, and is already present in the rewrite-gradle-plugin and moderne-cli through rewrite-polyglot. That means you should already be able to target Jenkinsfiles with Groovy recipes, although we have not yet added any Jenkins libraries to the classpath yet, so there might still be missing types. Figured worth posting that update here, and see where we might want to take this next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

None yet

2 participants