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 · 1 comment
Open

Some Jenkinsfile are not parsable by Groovy parser #580

jonesbusy opened this issue Jan 6, 2025 · 1 comment

Comments

@jonesbusy
Copy link
Collaborator

jonesbusy commented Jan 6, 2025

Plugin Modernizer version

1158.va_b_46a_2a_dde30

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

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