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

Some Jenkinsfile are not parsable by Groovy parser #580

Open
jonesbusy opened this issue Jan 6, 2025 · 3 comments
Open

Some Jenkinsfile are not parsable by Groovy parser #580

jonesbusy opened this issue Jan 6, 2025 · 3 comments

Comments

@jonesbusy
Copy link
Collaborator

jonesbusy commented Jan 6, 2025

Plugin Modernizer version

1222.vd800e48b_87e5

What Operating System are you using

Linux

Reproduction steps

plugin-modernizer run --plugins ssh --recipe UpgradeToRecommendCoreVersion --debug

I'm wonder if it's due to the shebang, but OpenRewrite is not able to parse following Jenkinsfile

#!/usr/bin/env groovy

/* `buildPlugin` step provided by: https://github.com/jenkins-infra/pipeline-library */
buildPlugin(
        useContainerAgent: true,
        configurations: [
                [platform: 'linux', jdk: 21],
                [platform: 'windows', jdk: 17],
        ])
[INFO] Project [Jenkins SSH plugin] Resolving Poms...
[INFO] Project [Jenkins SSH plugin] Parsing source files
[WARNING] There were problems parsing some source files, run with --errors to see full stack traces
[WARNING] There were problems parsing Jenkinsfile

Expected Results

The point is that it prevent to use other recipe because we assume the JDK is Java 8 (buildPlugin() with implicit version).

Since the metadata correctly contains the Jenkins version

{"pluginName":"Jenkins SSH plugin","flags":["DEVELOPER_SET","SCM_HTTPS","MAVEN_REPOSITORIES_HTTPS"],"commonFiles":["DEPENDABOT","README","WORKFLOW_SECURITY","MAVEN_CONFIG","INDEX_JELLY","WORKFLOW_CD","JENKINSFILE","GITIGNORE","POM","MAVEN_EXTENSIONS","CODEOWNERS"],"jenkinsVersion":"2.426.3","parentVersion":"4.88","bomVersion":"3208.vb_21177d4b_cd9","bomArtifactId":"bom-${jenkins.baseline}.x","properties":{"changelist":"999999-SNAPSHOT","jenkins.baseline":"2.426","jenkins.version":"${jenkins.baseline}.3","gitHubRepo":"jenkinsci/${project.artifactId}-plugin","spotless.check.skip":"false"},"key":"plugin-metadata","path":"ssh"}

We could easily detect the minimum version using

JDK.get(jenkinsVersion)

Which in that case would return Java 11

jonesbusy added a commit to jonesbusy/plugin-modernizer-tool that referenced this issue Jan 7, 2025
jonesbusy added a commit that referenced this issue Jan 7, 2025
Avoid hardcoding implicit JDK and workarround #580
@jonesbusy
Copy link
Collaborator Author

Workaround implemented on #583

Keeping it open to understand the root cause and perhaps propose a fix on openrewrite-groovy

gounthar pushed a commit to gounthar/plugin-modernizer-tool that referenced this issue Jan 8, 2025
@jonesbusy
Copy link
Collaborator Author

To test again with maven rewrite plugin 6.0.0 since significant bug fixes where fixed on the groovy parser

jonesbusy added a commit to jonesbusy/plugin-modernizer-tool that referenced this issue Jan 11, 2025
@jonesbusy
Copy link
Collaborator Author

Same. Created upstream issue : java.lang.StringIndexOutOfBoundsException: String index out of range: 287

jonesbusy added a commit that referenced this issue Jan 11, 2025
gounthar pushed a commit to gounthar/plugin-modernizer-tool that referenced this issue Jan 12, 2025
jonesbusy added a commit that referenced this issue Jan 13, 2025
* chore(deps): bump org.kohsuke.stapler:stapler

Bumps [org.kohsuke.stapler:stapler](https://github.com/jenkinsci/stapler) from 1940.v41211a_a_b_b_d8b_ to 1942.v708e07325402.
- [Release notes](https://github.com/jenkinsci/stapler/releases)
- [Changelog](https://github.com/jenkinsci/stapler/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jenkinsci/stapler/commits)

---
updated-dependencies:
- dependency-name: org.kohsuke.stapler:stapler
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

* Update README.md

* Cleanup and fix tests

* Add a Java ISO visitor for metadata collection

* Demonstrate test for #580

* Reduce build time by skipping by default slow integration tests and
setup Junit 5 parallel

* WiP

* fix(jte): Use conventional commit for the title, and create a custom body for the Dependabot recipe.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Palash Chitnavis <[email protected]>
Co-authored-by: Valentin Delaye <[email protected]>
nagu165 pushed a commit to nagu165/plugin-modernizer-tool that referenced this issue Jan 13, 2025
* chore(deps): bump org.kohsuke.stapler:stapler

Bumps [org.kohsuke.stapler:stapler](https://github.com/jenkinsci/stapler) from 1940.v41211a_a_b_b_d8b_ to 1942.v708e07325402.
- [Release notes](https://github.com/jenkinsci/stapler/releases)
- [Changelog](https://github.com/jenkinsci/stapler/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jenkinsci/stapler/commits)

---
updated-dependencies:
- dependency-name: org.kohsuke.stapler:stapler
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

* Update README.md

* Cleanup and fix tests

* Add a Java ISO visitor for metadata collection

* Demonstrate test for jenkins-infra#580

* Reduce build time by skipping by default slow integration tests and
setup Junit 5 parallel

* WiP

* fix(jte): Use conventional commit for the title, and create a custom body for the Dependabot recipe.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Palash Chitnavis <[email protected]>
Co-authored-by: Valentin Delaye <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant