jenkinsci / plugin-modernizer-tool

MIT License
9 stars 6 forks source link

Forking fails in GitPod #125

Closed sridamul closed 1 month ago

sridamul commented 2 months ago

Jenkins and plugins versions report

java -jar plugin-modernizer-cli/target/jenkins-plugin-modernizer-999999-SNAPSHOT.jar --plugins open-stf --recipes AddPluginsBom,AddCodeOwner -n When I execute the tool via gitpod, the forking process should be successful but it fails

What Operating System are you using (both controller, and any agents involved in the problem)?

GitPod

Reproduction steps

Execute the modernizer tool with any plugins in gitpod

Expected Results

Successful forking

Actual Results

Forking fails

Picked up JAVA_TOOL_OPTIONS: -XX:+UseContainerSupport -XX:ActiveProcessorCount=1
Starting Plugin Modernizer 
Picked up JAVA_TOOL_OPTIONS: -XX:+UseContainerSupport -XX:ActiveProcessorCount=1
Plugins: [open-stf] 
Recipes: [AddPluginsBom, AddCodeOwner] 
GitHub owner: sridamul 
Update Center Url: https://updates.jenkins.io/current/update-center.actual.json 
Creating cache at /home/gitpod/.cache/jenkins-plugin-modernizer-cli 
Forking and cloning plugin open-stf locally from repo open-stf-plugin 
Forking the repository to personal account... 
Failed to process plugin: open-stf 
org.kohsuke.github.GHFileNotFoundException: https://api.github.com/repos/jenkinsci/open-stf-plugin/forks {"message":"Not Found","documentation_url":"https://docs.github.com/rest/repos/forks#create-a-fork","status":"404"}
        at org.kohsuke.github.GitHubClient.interpretApiError(GitHubClient.java:737)
        at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:480)
        at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:427)
        at org.kohsuke.github.Requester.send(Requester.java:70)
        at org.kohsuke.github.GHRepository.fork(GHRepository.java:1600)
        at io.jenkins.tools.pluginmodernizer.core.github.GHService.forkRepository(GHService.java:116)
        at io.jenkins.tools.pluginmodernizer.core.github.GHService.forkRepository(GHService.java:127)
        at io.jenkins.tools.pluginmodernizer.core.github.GHService.forkRepository(GHService.java:91)
        at io.jenkins.tools.pluginmodernizer.core.github.GHService.forkCloneAndCreateBranch(GHService.java:71)
        at io.jenkins.tools.pluginmodernizer.core.impl.PluginModernizer.start(PluginModernizer.java:53)
        at io.jenkins.tools.pluginmodernizer.cli.Main.run(Main.java:145)
        at picocli.CommandLine.executeUserObject(CommandLine.java:2030)
        at picocli.CommandLine.executeHelpRequest(CommandLine.java:2016)
        at picocli.CommandLine.executeHelpRequest(CommandLine.java:1987)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2272)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2421)
        at picocli.CommandLine.execute(CommandLine.java:2174)
        at io.jenkins.tools.pluginmodernizer.cli.Main.main(Main.java:35)
Caused by: java.io.FileNotFoundException: https://api.github.com/repos/jenkinsci/open-stf-plugin/forks
        at org.kohsuke.github.GitHubConnectorResponseErrorHandler$1.onError(GitHubConnectorResponseErrorHandler.java:68)
        at org.kohsuke.github.GitHubClient.detectKnownErrors(GitHubClient.java:504)
        at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:464)
        ... 16 common frames omitted

Anything else?

The tool works fine in the local environment.

Are you interested in contributing a fix?

No response

jonesbusy commented 2 months ago

Is it because https://github.com/jenkinsci/open-stf-plugin is a fork already ?

In any case I would suggest @gounthar to detach the fork via GH support (You need to be admin of the repo to do it, the process is semi-automated via a bot. I've actionned it several times in the past year for plugins I adopted)

sridamul commented 2 months ago

Is it because https://github.com/jenkinsci/open-stf-plugin is a fork already ?

If that were a reason, then normal repos like login-theme-plugin should be forked, right? But the issue arises for any plugin (forked repo or a normal repo) Log for Login-theme-plugin execution:

Picked up JAVA_TOOL_OPTIONS: -XX:+UseContainerSupport -XX:ActiveProcessorCount=1
Starting Plugin Modernizer 
Picked up JAVA_TOOL_OPTIONS: -XX:+UseContainerSupport -XX:ActiveProcessorCount=1
Plugins: [login-theme] 
Recipes: [AddPluginsBom, AddCodeOwner] 
GitHub owner: sridamul 
Update Center Url: https://updates.jenkins.io/current/update-center.actual.json 
Forking and cloning plugin login-theme locally from repo login-theme-plugin 
Forking the repository to personal account... 
Failed to process plugin: login-theme 
org.kohsuke.github.GHFileNotFoundException: https://api.github.com/repos/jenkinsci/login-theme-plugin/forks {"message":"Not Found","documentation_url":"https://docs.github.com/rest/repos/forks#create-a-fork","status":"404"}
        at org.kohsuke.github.GitHubClient.interpretApiError(GitHubClient.java:737)
        at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:480)
        at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:427)
        at org.kohsuke.github.Requester.send(Requester.java:70)
        at org.kohsuke.github.GHRepository.fork(GHRepository.java:1600)
        at io.jenkins.tools.pluginmodernizer.core.github.GHService.forkRepository(GHService.java:116)
        at io.jenkins.tools.pluginmodernizer.core.github.GHService.forkRepository(GHService.java:127)
        at io.jenkins.tools.pluginmodernizer.core.github.GHService.forkRepository(GHService.java:91)
        at io.jenkins.tools.pluginmodernizer.core.github.GHService.forkCloneAndCreateBranch(GHService.java:71)
        at io.jenkins.tools.pluginmodernizer.core.impl.PluginModernizer.start(PluginModernizer.java:53)
        at io.jenkins.tools.pluginmodernizer.cli.Main.run(Main.java:145)
        at picocli.CommandLine.executeUserObject(CommandLine.java:2030)
        at picocli.CommandLine.executeHelpRequest(CommandLine.java:2016)
        at picocli.CommandLine.executeHelpRequest(CommandLine.java:1987)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2272)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2421)
        at picocli.CommandLine.execute(CommandLine.java:2174)
        at io.jenkins.tools.pluginmodernizer.cli.Main.main(Main.java:35)
Caused by: java.io.FileNotFoundException: https://api.github.com/repos/jenkinsci/login-theme-plugin/forks
        at org.kohsuke.github.GitHubConnectorResponseErrorHandler$1.onError(GitHubConnectorResponseErrorHandler.java:68)
        at org.kohsuke.github.GitHubClient.detectKnownErrors(GitHubClient.java:504)
        at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:464)
        ... 16 common frames omitted

Also, the tool forks the open-stf in local env, the issue only exists in GitPod

gounthar commented 2 months ago

@sridamul could you please try with a token of yours, and not the default token generated by GitPod? Thanks. šŸ™

gounthar commented 2 months ago

Okay, I tried with a standard GitHub token, and got the same problem, with a different output:

Failed to process plugin: TwilioNotifier 
org.eclipse.jgit.api.errors.TransportException: https://github.com/gounthar/twilio-notifier-plugin.git: Authentication is required but no CredentialsProvider has been registered
        at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:249)
        at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:319)
        at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:189)
        at io.jenkins.tools.pluginmodernizer.core.github.GHService.fetchRepository(GHService.java:137)
        at io.jenkins.tools.pluginmodernizer.core.github.GHService.forkCloneAndCreateBranch(GHService.java:72)
        at io.jenkins.tools.pluginmodernizer.core.impl.PluginModernizer.start(PluginModernizer.java:53)
        at io.jenkins.tools.pluginmodernizer.cli.Main.run(Main.java:145)
        at picocli.CommandLine.executeUserObject(CommandLine.java:2030)
        at picocli.CommandLine.executeHelpRequest(CommandLine.java:2016)
        at picocli.CommandLine.executeHelpRequest(CommandLine.java:1987)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2272)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2421)
        at picocli.CommandLine.execute(CommandLine.java:2174)
        at io.jenkins.tools.pluginmodernizer.cli.Main.main(Main.java:35)
Caused by: org.eclipse.jgit.errors.TransportException: https://github.com/gounthar/twilio-notifier-plugin.git: Authentication is required but no CredentialsProvider has been registered
        at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:687)
        at org.eclipse.jgit.transport.TransportHttp.openFetch(TransportHttp.java:465)
        at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:153)
        at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:105)
        at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1480)
        at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:238)
        ... 13 common frames omitted

In the end, the plugin is forked to my personal account despite the exception. šŸ¤”

I also tried to fork the same repo (once deleted) thanks to gh, and it worked within the GitPod workspace:

gh repo fork  https://github.com/jenkinsci/twilio-notifier-plugin.git
āœ“ Created fork gounthar/twilio-notifier-plugin
? Would you like to clone the fork? Yes
Cloning into 'twilio-notifier-plugin'...
remote: Enumerating objects: 379, done.
remote: Total 379 (delta 0), reused 0 (delta 0), pack-reused 379
Receiving objects: 100% (379/379), 38.74 KiB | 2.98 MiB/s, done.
Resolving deltas: 100% (95/95), done.
From https://github.com/jenkinsci/twilio-notifier-plugin
 * [new branch]      master     -> upstream/master
āœ“ Cloned fork
! Repository jenkinsci/twilio-notifier-plugin set as the default repository. To learn more about the default repository, run: gh repo set-default --help
gounthar commented 2 months ago

I also tried several times to delete a fork on my account, and let the modernized tool recreate it for me with GitPod, and it worked. šŸ¤”

java -jar plugin-modernizer-cli/target/jenkins-plugin-modernizer-999999-SNAPSHOT.jar --dry-run --plugins login-theme --recipes AddPluginsBom,AddCodeOwner --export-datatables
Picked up JAVA_TOOL_OPTIONS: -XX:+UseContainerSupport -XX:ActiveProcessorCount=1
Starting Plugin Modernizer 
Picked up JAVA_TOOL_OPTIONS: -XX:+UseContainerSupport -XX:ActiveProcessorCount=1
Plugins: [login-theme] 
Recipes: [AddPluginsBom, AddCodeOwner] 
GitHub owner: gounthar 
Update Center Url: https://updates.jenkins.io/current/update-center.actual.json 
Forking and cloning plugin login-theme locally from repo login-theme-plugin 
Forking the repository to personal account... 
Repository forked to personal account successfully. 
Branch already exists. Checking out the branch. 
Invoking clean phase for plugin: login-theme 
Invoking rewrite plugin for plugin: login-theme 
Skipping commit and pull request creation for login-theme 
jonesbusy commented 1 month ago

Is is still reproducible or can be closed ?

gounthar commented 1 month ago

Let me retry it...

gounthar commented 1 month ago

It seems to work now, we can close. Thanks.