KostyaSha / github-integration-plugin

Jenkins GitHub Integration Plugin
https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Integration+Plugin
MIT License
98 stars 86 forks source link

Github PR -> Build or Github PR -> "Rebuild last build" button does not work any more #383

Closed RealCLanger closed 11 months ago

RealCLanger commented 1 year ago

After updating Jenkins to the latest LTS version, the GitHub PR Build/Rebuild Last build functionality seems to be broken.

Clicking the "Build" button, I get: "No branch to build", probably corresponding to that LOC: https://github.com/KostyaSha/github-integration-plugin/blob/84e81c07edbf2d27b30c40dcec53b39e30460423/github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/GitHubPRRepository.java#L211C46-L211C64

For "Rebuild last build" I see: "Build not found", corresponding to https://github.com/KostyaSha/github-integration-plugin/blob/84e81c07edbf2d27b30c40dcec53b39e30460423/github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/GitHubPRRepository.java#L257C50-L257C65

Did maybe something change and the Github integration does not get the current PR data? I'm a bit out of my wits here. Maybe you have a hint?

Thanks Christoph

KostyaSha commented 1 year ago

It looks up prs in internal state. State should be populated first. Do you have anything in logs?

RealCLanger commented 1 year ago

It looks up prs in internal state. State should be populated first. Do you have anything in logs?

Hm, any hint which logs to enable?

mal-risma commented 1 year ago

We're getting the same errors after our last update to 2.426.1.

KostyaSha commented 1 year ago

Please try to add loggers com.github.kostyasha.github and org.jenkinsci.plugins.github.pullrequest without any logs it's pretty difficult to find direction

mal-risma commented 1 year ago

Not much in the logs I'm afraid:

Nov 27, 2023 12:06:56 PM FINE org.jenkinsci.plugins.github.pullrequest.GitHubPRRepository getAllPrBuilds Got builds for job Risma2 - PR - Backend

KostyaSha commented 1 year ago

What else changed beside core version? Was github-api-plugin updated also?

RealCLanger commented 1 year ago

This is my version history for Jenkins, the github-api plugin and github-integration plugin:

11/21 Jenkins 2.426.1 11/08 Jenkins 2.414.3 09/22 Jenkins 2.414.2

11/25 github-api: "1.318-461.v7a_c09c9fa_d63" 10/05 github-api: "1.316-451.v15738eef3414" 05/19 github-api: "1.316-451.v15738eef3414"

03/01 github-integration: 0.5.0 22/06/07 github-integration: 0.4.0

I believe the issue occurs since early November, but I can't tell it exactly any more. It was definitely there after the update to Jenkins 2.426.1 on November 11/21. But I'm pretty sure it was there even before. Maybe it was introduced on 11/08 with the update to Jenkins 2.414.3. But a relation to the github-api update on 10/05 is unlikely because I'm also pretty certain the functionality worked back in October.

Is there any other plugin where you'd be interested in the history?

I didn't get to look deeper into the logs or even try with debugging. Maybe I'll find some time for this...

RealCLanger commented 1 year ago

From looking at the code, the content of getPulls() here is probably empty or does not contain the prId. Any hints on where this is supposed to get filled? Maybe in LocalRepoUpdater? Where is this called from?

agentili commented 12 months ago

I'm also having the same kind of issue.

I have updated my Jenkins (based on docker images here) from 2.354-jdk11 to the 2.426.1-lts

Version of the plugin has been upgrade from 0.4.0 to 0.5.0

BTW, any news on this side?

KostyaSha commented 12 months ago

I run locally with the next version:

GitHub plugin 1.37.3.1
github-api plugin 451.v15738eef3414
core 1.426.1

Manage Jenkins -> System -> Github has user with a valid token. Freestyle job with a repository url, strategy: cron, triggering: pr open. Then i go to "GitHub PR" on the left sidebar and press "Run GH PR trigger" and monitor Polling log for changes. I also checked Build button. Java 11.

RealCLanger commented 12 months ago

I run locally with the next version:

GitHub plugin 1.37.3.1
github-api plugin 451.v15738eef3414
core 1.426.1

Manage Jenkins -> System -> Github has user with a valid token. Freestyle job with a repository url, strategy: cron, triggering: pr open. Then i go to "GitHub PR" on the left sidebar and press "Run GH PR trigger" and monitor Polling log for changes. I also checked Build button. Java 11.

Hm, I don't get the versions you are referring to. I also don't understand whether you could reproduce it or not.

RealCLanger commented 12 months ago

I debugged this. The problem is that here the request does not contain a parameter prNumber. It must somehow get lost. On the browser client side, I can see that the source code for the rebuild button contains this: onsubmit="return callFeature(this, rebuildResult1556, {'prNumber' : 1556 })".

Any idea?

KostyaSha commented 12 months ago

there is one PR merged https://github.com/KostyaSha/github-integration-plugin/pull/382 but it mentioned that it not required. I will make a release with this change, maybe it will help

KostyaSha commented 12 months ago

Please try 0.6.1 version (should appear later in update center)

RealCLanger commented 12 months ago

Great, seems that's it! The old 0.6.0 version even had the featureButton.js from before 00b90176cdc1bf8f2a07b98d39dfab618e2dca5f and that was a more significant change, I guess.

KostyaSha commented 12 months ago

I thought about https://github.com/KostyaSha/github-integration-plugin/pull/382/files

RealCLanger commented 12 months ago

Whatever it was, I don't understand that js stuff. But it works now. 😄

KostyaSha commented 12 months ago

I don't understand that js stuff.

heavy plus one :D Thanks for reporting and testing!

mal-risma commented 11 months ago

This fixed it for us as well. Thank you guys!