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

Recipe to update SCM url #538

Closed
jonesbusy opened this issue Dec 30, 2024 · 13 comments
Closed

Recipe to update SCM url #538

jonesbusy opened this issue Dec 30, 2024 · 13 comments
Labels
good first issue Good for newcomers

Comments

@jonesbusy
Copy link
Collaborator

jonesbusy commented Dec 30, 2024

What feature do you want to see added?

An OpenRewrite recipe to ensure scm tags are set correctly for plugin.

See https://www.jenkins.io/doc/developer/tutorial-improve/update-scm-url/ for the context

Test should be provided

  • missing tag for a plugin
  • without incrementals (using repository name for metadata)
  • with incrementals (using github maven property)

Upstream changes

No response

Are you interested in contributing this feature?

No response

@jonesbusy jonesbusy added the good first issue Good for newcomers label Dec 30, 2024
@CodexRaunak CodexRaunak mentioned this issue Jan 1, 2025
6 tasks
@AkhilYadavPadala
Copy link

Heyy @jonesbusy,Can I work on this issue?

@jonesbusy
Copy link
Collaborator Author

Sure nobody started it. On most jenkins repository we don't assign issues. So feel free to work on any on it.

@jonesbusy
Copy link
Collaborator Author

See #549 (comment) if the goal is not clear

@nagu165
Copy link
Contributor

nagu165 commented Jan 1, 2025

Hello sir, I was trying to work on this and am stuck here
Screenshot 2025-01-02 000000

The rewrite.yml file is shown in the figure
when i tried to dryRun you can see in the figure that it's throwing "Applying recipes would make no changes. No patch file generated."
Based on the openrewrite documentation i've added the plugin as shown in the below figure as well but still throwing the same message.
Screenshot 2025-01-02 000916

Could you please look into it if possible.

Thank you.

@jonesbusy
Copy link
Collaborator Author

I suggest to take a look at the current code, tests and understand how plugin modernizer is working and calling the maven rewrite plugin via Maven Invoker

This recipe need most likely java code to manage the logic of scm tags. I don't think it can be achieved with declarative recipe only

Please take a look at already implemented recipes and visitors to understand how it's working.

@nagu165
Copy link
Contributor

nagu165 commented Jan 2, 2025

Hello sir,
As a beginner i sincerely apologize for the repeated cry for help.

I've added this recipe in the recipes.yml file in plugins-modernizer-core in META-INF/rewrite folder :

type: specs.openrewrite.org/v1beta/recipe
name: io.jenkins.tools.pluginmodernizer.UpdateScmUrl
displayName: Update scm urls from git:// to https://
description: Updates scm urls in POM files from git:// to https:// protocol as git:// protocol is deprecated by GitHub
tags: ['chore']
recipeList:

  • org.openrewrite.xml.ChangeXmlValue:
    xpath: "/project/scm/url"
    oldValue: "git://"
    newValue: "https://"
  • org.openrewrite.xml.ChangeXmlValue:
    xpath: "/project/scm/connection"
    oldValue: "scm:git:git://"
    newValue: "scm:git:https://"

I've also created both UpdateScmUrl.java file(in recipes folder) and UpdateScmUrlVisitor.java file(in visitors folder) based on the existing files.
Still showing "Applying recipes would make no changes. No patch file generated."

What am i missing?

Thank you.

@jonesbusy
Copy link
Collaborator Author

Perhaps this PR could help you https://github.com/jenkins-infra/plugin-modernizer-tool/pull/512/files#diff-31bafcc7a416e95c87a0df2a03a0a0267695c6740aa29122502a216fb0518135

I suggest to follow to test driven development approach

Write the tests first. What the pom should is before and after applying the recipe. Run it via maven or your IDE.

Also I don't know where you found org.openrewrite.xml.ChangeXmlValue on the XML catalog https://docs.openrewrite.org/recipes/xml

@nagu165
Copy link
Contributor

nagu165 commented Jan 2, 2025

Perhaps this PR could help you https://github.com/jenkins-infra/plugin-modernizer-tool/pull/512/files#diff-31bafcc7a416e95c87a0df2a03a0a0267695c6740aa29122502a216fb0518135

I suggest to follow to test driven development approach

Write the tests first. What the pom should is before and after applying the recipe. Run it via maven or your IDE.

Ok sir, Understood.

Also I don't know where you found org.openrewrite.xml.ChangeXmlValue on the XML catalog https://docs.openrewrite.org/recipes/xml

Sorry sir, It was ChangeTagValue.

@nagu165
Copy link
Contributor

nagu165 commented Jan 2, 2025

Hello sir, I would like some clarity on this
Since we are creating recipe classes to do the actual work, we don't need to use something like "org.openrewrite.xml.ChangeXmlValue" right?
Does this work?:
type: specs.openrewrite.org/v1beta/recipe
name: io.jenkins.tools.pluginmodernizer.UpdateScmUrl
displayName: Update scm urls from git:// to https://
description: Updates scm urls in POM files from git:// to https:// protocol as git:// protocol is deprecated by GitHub
tags: ['chore']
recipeList:

  • io.jenkins.tools.pluginmodernizer.core.recipes.UpdateScmUrl

That's how the other recipes were also implemented so i was wondering if it's the same here.

@jonesbusy
Copy link
Collaborator Author

Yes that's how you can define a top level recipe for plugin modernizer but is not mandatory if the recipe is not exposed directly by plugin modernizer (and used only in a list of recipeList of an other one)

@nagu165
Copy link
Contributor

nagu165 commented Jan 2, 2025

Hello sir, I have written the tests based on the other tests in the repository and am trying to find the reason why the recipes are not being sourced properly
Error message is as follows:
Screenshot 2025-01-02 181926

Should i open a pr as it would be better for you to see and deduce the mistakes easily like that.

Thank you.

@jonesbusy
Copy link
Collaborator Author

The recipe is throwing an error. Check logs before for more details.

Feel free to open a PR if you think it deserve a review

@jonesbusy
Copy link
Collaborator Author

Fixed by #560

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants