Closed simonzn closed 7 months ago
Thanks for the reminder/suggestion @simonzn ! I've added a first commit to parse any file that starts with Jenkinsfile as Groovy in https://github.com/openrewrite/rewrite/commit/7ed7222b17f689d57c9392fd6430f82fe301da1b.
The logic for which parsers to use in the rewrite-maven-plugin is here. https://github.com/openrewrite/rewrite-maven-plugin/blob/558223d80e56302d4ee1dc939653d5dec19383f3/src/main/java/org/openrewrite/maven/ResourceParser.java#L135-L247
Would you be open to adding the GroovyParser in there as well? Even a draft PR would be fine to get this going.
Thanks for your swift reply @timtebeek ! I meant to do that, but then I found #641 and realized there might be more to it.
I can absolutely extend the ResourceParser
. That should be sufficient for our use case, but probably not for rewriting actual Groovy projects.
Until the next release you can try out this change using our snapshot versions. Let me know how that works for you! :)
I tested the snapshots with our Jenkinsfile recipes, everything works as expected now :-) Thanks a lot!
What problem are you trying to solve?
We use Maven plugins for all CI tasks and would also like to run rewrite recipes for updating Jenkinsfiles through this plugin.
Describe the solution you'd like
The GroovyParser is already able to parse Jenkinsfiles, and I have tested it successfully with our pipelines. We would like the Maven plugin to parse Jenkinsfiles as Groovy sources by default instead of Quarks.
Currently the name must be "Jenkinsfile":
We have two pipelines in each repository, "Jenkinsfile" for building the project and "Jenkinsfile_Release" for releasing it. It is quite common to have some suffix for Jenkinsfiles, so we would like the GroovyParser to accept
Jenkinsfile*
(or maybe even*Jenkinsfile*
to support prefixes as well - although we don't use them).Have you considered any alternatives or workarounds?
Currently we execute text recipes on Jenkinsfiles by passing
-Drewrite.plainTextMasks="**/Jenkinsfile*,...
(otherwise they are only added as Quarks). This works for us for now, but may become limiting. Adding the GroovyParser would also mean we could use text recipes without modifying the plainTextMasks.