From ff97c8a1f804ae9a0c51123e351f2b3ea867798f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 3 Aug 2023 18:19:51 -0400 Subject: [PATCH 01/37] Bump plugin from 4.66 to 4.67 (#710) Bumps [plugin](https://github.com/jenkinsci/plugin-pom) from 4.66 to 4.67. - [Release notes](https://github.com/jenkinsci/plugin-pom/releases) - [Changelog](https://github.com/jenkinsci/plugin-pom/blob/master/CHANGELOG.md) - [Commits](https://github.com/jenkinsci/plugin-pom/compare/plugin-4.66...plugin-4.67) --- updated-dependencies: - dependency-name: org.jenkins-ci.plugins:plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1d608f2b4..912cb1339 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.plugins plugin - 4.66 + 4.67 From d5dc73d85c0e9073c367b5ea7c58fdcd45707520 Mon Sep 17 00:00:00 2001 From: James Nord Date: Mon, 7 Aug 2023 15:41:19 +0100 Subject: [PATCH 02/37] deflake GithubAppCredentialsAppInstallationTokenTest In CI have have seen flakes from GithubAppCredentialsAppInstallationTokenTest. inpsecting the logs shows the flakes are occuring as the CI system is too slow and has just pased the 5 seconds configured for the cache timeout when it was not expecting it to. Increase the timeout to 10 seconds to reduce the flakes (which will unfortunately increate the test time slightly of these tests) --- .../github_branch_source/GithubAppCredentialsTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubAppCredentialsTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubAppCredentialsTest.java index 071c164aa..b73219d03 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubAppCredentialsTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubAppCredentialsTest.java @@ -290,7 +290,7 @@ public void testProviderRefresh() throws Exception { // We want to demonstrate successful caching without waiting for the default 1 minute // Must set this to a large enough number to avoid flaky test - GitHubAppCredentials.AppInstallationToken.NOT_STALE_MINIMUM_SECONDS = 5; + GitHubAppCredentials.AppInstallationToken.NOT_STALE_MINIMUM_SECONDS = 10; // Ensure we are working from sufficiently clean cache state Thread.sleep(Duration.ofSeconds(GitHubAppCredentials.AppInstallationToken.NOT_STALE_MINIMUM_SECONDS + 2) @@ -362,7 +362,7 @@ public void testAgentRefresh() throws Exception { // We want to demonstrate successful caching without waiting for a the default 1 minute // Must set this to a large enough number to avoid flaky test - GitHubAppCredentials.AppInstallationToken.NOT_STALE_MINIMUM_SECONDS = 5; + GitHubAppCredentials.AppInstallationToken.NOT_STALE_MINIMUM_SECONDS = 10; // Ensure we are working from sufficiently clean cache state Thread.sleep(Duration.ofSeconds(GitHubAppCredentials.AppInstallationToken.NOT_STALE_MINIMUM_SECONDS + 2) @@ -479,7 +479,7 @@ public void testPassword() throws Exception { // We want to demonstrate successful caching without waiting for the default 1 minute // Must set this to a large enough number to avoid flaky test - GitHubAppCredentials.AppInstallationToken.NOT_STALE_MINIMUM_SECONDS = 5; + GitHubAppCredentials.AppInstallationToken.NOT_STALE_MINIMUM_SECONDS = 10; // Ensure we are working from sufficiently clean cache state Thread.sleep(Duration.ofSeconds(GitHubAppCredentials.AppInstallationToken.NOT_STALE_MINIMUM_SECONDS + 2) From 9e45152619f4a313e5c4136c1c1a9c4392f39635 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Tue, 29 Aug 2023 16:41:43 -0700 Subject: [PATCH 03/37] PCT compatibility with `cloudbees-bitbucket-branch-source` --- .mvn/extensions.xml | 2 +- pom.xml | 6 ++---- .../GitHubSCMSourceTraitsTest.java | 13 +++++++++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml index 90787cbb2..1f3636409 100644 --- a/.mvn/extensions.xml +++ b/.mvn/extensions.xml @@ -2,6 +2,6 @@ io.jenkins.tools.incrementals git-changelist-maven-extension - 1.6 + 1.7 diff --git a/pom.xml b/pom.xml index 912cb1339..71b33c9b8 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.plugins plugin - 4.67 + 4.72 @@ -43,7 +43,7 @@ io.jenkins.tools.bom bom-2.387.x - 2163.v2d916d90c305 + 2378.v3e03930028f2 pom import @@ -66,8 +66,6 @@ io.jenkins.plugins okhttp-api - - 4.10.0-136.v1d8ce1b_1db_72 org.jenkins-ci.plugins diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTraitsTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTraitsTest.java index e6de59ed0..9454ddcdf 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTraitsTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTraitsTest.java @@ -75,6 +75,15 @@ public void given__configuredInstance__when__uninstantiating__then__deprecatedFi } else { trust = "TrustPermission"; } + String originTrait; + String forkTrait; + if (r.jenkins.getPlugin("cloudbees-bitbucket-branch-source") != null) { + originTrait = "org.jenkinsci.plugins.github_branch_source.OriginPullRequestDiscoveryTrait"; + forkTrait = "org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait"; + } else { + originTrait = "OriginPullRequestDiscoveryTrait"; + forkTrait = "ForkPullRequestDiscoveryTrait"; + } assertThat( DescribableModel.uninstantiate2_(recreated).toString(), is("@github(" @@ -84,8 +93,8 @@ public void given__configuredInstance__when__uninstantiating__then__deprecatedFi + "repository=repo," + "traits=[" + "@gitHubBranchDiscovery$org.jenkinsci.plugins.github_branch_source.BranchDiscoveryTrait(strategyId=1), " - + "@gitHubPullRequestDiscovery$OriginPullRequestDiscoveryTrait(strategyId=1), " - + "@gitHubForkDiscovery$ForkPullRequestDiscoveryTrait(" + + "@gitHubPullRequestDiscovery$" + originTrait + "(strategyId=1), " + + "@gitHubForkDiscovery$" + forkTrait + "(" + "strategyId=2," + "trust=@gitHubTrustPermissions$" + trust From 5fb187ec34edec723d2e959f1640e8184a9770a7 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 8 Sep 2023 19:40:24 +0200 Subject: [PATCH 04/37] .editorconfig: fix indentation by IntelliJ editorconfig plugin auto-formatting support (#722) --- .editorconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.editorconfig b/.editorconfig index beffa3084..711b59f2d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,3 +9,7 @@ insert_final_newline = true [*.md] trim_trailing_whitespace = false + +[*.java] +ij_continuation_indent_size = 8 +indent_size = 4 From d0443ab0c1627f24acf53e12723bc77d32cf96f1 Mon Sep 17 00:00:00 2001 From: Steve Hill <107283246+sghill-rewrite@users.noreply.github.com> Date: Fri, 8 Sep 2023 10:41:01 -0700 Subject: [PATCH 05/37] chore(CODEOWNERS): add plugin development team (#721) Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.jenkins.github.AddTeamToCodeowners Co-authored-by: Moderne --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..f94f869bb --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @jenkinsci/github-branch-source-plugin-developers From c5dd27ff23e79a8b91c68e9ed185fe833749adeb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Sep 2023 13:41:16 -0400 Subject: [PATCH 06/37] Bump io.jenkins.tools.incrementals:git-changelist-maven-extension (#712) Bumps [io.jenkins.tools.incrementals:git-changelist-maven-extension](https://github.com/jenkinsci/incrementals-tools) from 1.6 to 1.7. - [Release notes](https://github.com/jenkinsci/incrementals-tools/releases) - [Commits](https://github.com/jenkinsci/incrementals-tools/compare/parent-1.6...parent-1.7) --- updated-dependencies: - dependency-name: io.jenkins.tools.incrementals:git-changelist-maven-extension dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> From ff8f6191c7c817478e7461daeb2769a7710166bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Sep 2023 13:41:31 -0400 Subject: [PATCH 07/37] Bump org.jenkins-ci.plugins:plugin from 4.67 to 4.73 (#725) Bumps [org.jenkins-ci.plugins:plugin](https://github.com/jenkinsci/plugin-pom) from 4.67 to 4.73. - [Release notes](https://github.com/jenkinsci/plugin-pom/releases) - [Changelog](https://github.com/jenkinsci/plugin-pom/blob/master/CHANGELOG.md) - [Commits](https://github.com/jenkinsci/plugin-pom/compare/plugin-4.67...plugin-4.73) --- updated-dependencies: - dependency-name: org.jenkins-ci.plugins:plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 71b33c9b8..5ea7b175f 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.plugins plugin - 4.72 + 4.73 From 42897b9461865ae83a8eb4a6e23712e81de587ba Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Sep 2023 13:41:53 -0400 Subject: [PATCH 08/37] Bump com.github.tomakehurst:wiremock-jre8-standalone (#727) Bumps [com.github.tomakehurst:wiremock-jre8-standalone](https://github.com/wiremock/wiremock) from 2.35.0 to 2.35.1. - [Release notes](https://github.com/wiremock/wiremock/releases) - [Commits](https://github.com/wiremock/wiremock/compare/2.35.0...2.35.1) --- updated-dependencies: - dependency-name: com.github.tomakehurst:wiremock-jre8-standalone dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5ea7b175f..c7df1d675 100644 --- a/pom.xml +++ b/pom.xml @@ -82,7 +82,7 @@ com.github.tomakehurst wiremock-jre8-standalone - 2.35.0 + 2.35.1 test From 51d5810e9e8c15d7b4835bc6eb19fb882ffdf8e6 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Fri, 15 Sep 2023 11:28:51 -0400 Subject: [PATCH 09/37] [JENKINS-71849] Allow `NoThrottle` to be used even on github.com (#653) * [JENKINS-68321] Allow `NoThrottle` to be used even on github.com * Ignoring failing tests --- .../ApiRateLimitChecker.java | 23 ++++++------------- .../ApiRateLimitCheckerTest.java | 3 +++ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitChecker.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitChecker.java index 57ce199ad..c845dbc07 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitChecker.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitChecker.java @@ -100,22 +100,13 @@ long checkRateLimitImpl(@NonNull GHRateLimit.Record rateLimit, long count, long NoThrottle(Messages.ApiRateLimitChecker_NoThrottle()) { @Override public LocalChecker getChecker(@NonNull TaskListener listener, String apiUrl) { - if (GitHubServerConfig.GITHUB_URL.equals(apiUrl)) { - // If the GitHub public API is being used, this will fallback to ThrottleOnOver - LocalChecker checker = ThrottleOnOver.getChecker(listener, apiUrl); - checker.writeLog( - "GitHub throttling is disabled, which is not allowed for public GitHub usage, " - + "so ThrottleOnOver will be used instead. To configure a different rate limiting strategy, go to \"GitHub API usage\" under \"Configure System\" in the Jenkins settings."); - return checker; - } else { - return new LocalChecker(listener) { - @Override - long checkRateLimitImpl(@NonNull GHRateLimit.Record rateLimit, long count, long now) - throws InterruptedException { - return now; - } - }; - } + return new LocalChecker(listener) { + @Override + long checkRateLimitImpl(@NonNull GHRateLimit.Record rateLimit, long count, long now) + throws InterruptedException { + return now; + } + }; } }; diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java index a47d6eb4c..89fb5fe7b 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java @@ -27,6 +27,7 @@ import org.jenkinsci.plugins.github.config.GitHubServerConfig; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.kohsuke.github.GHRateLimit; import org.kohsuke.github.GitHub; @@ -159,6 +160,7 @@ private void setupStubs(List scenarios) throws Exception { assertEquals(2, initialRequestCount); } + @Ignore("behavior deliberately modified") @Test public void NoCheckerConfigured() throws Exception { // set up scenarios @@ -349,6 +351,7 @@ public void NoThrottleTestShouldNotThrottle404() throws Exception { * * @author Marc Salles Navarro */ + @Ignore("behavior deliberately modified") @Test public void NoThrottleTestShouldFallbackToThrottleOnOverForGitHubDotCom() throws Exception { GitHubConfiguration.get().setApiRateLimitChecker(ApiRateLimitChecker.ThrottleOnOver); From a3028eb9fd2180459efc511b30e9dd46937d44fd Mon Sep 17 00:00:00 2001 From: Carroll Chiou Date: Mon, 18 Sep 2023 10:33:52 -0600 Subject: [PATCH 10/37] Revert "[JENKINS-71849] Allow `NoThrottle` to be used even on github.com (#653)" (#730) This reverts commit 51d5810e9e8c15d7b4835bc6eb19fb882ffdf8e6. --- .../ApiRateLimitChecker.java | 23 +++++++++++++------ .../ApiRateLimitCheckerTest.java | 3 --- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitChecker.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitChecker.java index c845dbc07..57ce199ad 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitChecker.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitChecker.java @@ -100,13 +100,22 @@ long checkRateLimitImpl(@NonNull GHRateLimit.Record rateLimit, long count, long NoThrottle(Messages.ApiRateLimitChecker_NoThrottle()) { @Override public LocalChecker getChecker(@NonNull TaskListener listener, String apiUrl) { - return new LocalChecker(listener) { - @Override - long checkRateLimitImpl(@NonNull GHRateLimit.Record rateLimit, long count, long now) - throws InterruptedException { - return now; - } - }; + if (GitHubServerConfig.GITHUB_URL.equals(apiUrl)) { + // If the GitHub public API is being used, this will fallback to ThrottleOnOver + LocalChecker checker = ThrottleOnOver.getChecker(listener, apiUrl); + checker.writeLog( + "GitHub throttling is disabled, which is not allowed for public GitHub usage, " + + "so ThrottleOnOver will be used instead. To configure a different rate limiting strategy, go to \"GitHub API usage\" under \"Configure System\" in the Jenkins settings."); + return checker; + } else { + return new LocalChecker(listener) { + @Override + long checkRateLimitImpl(@NonNull GHRateLimit.Record rateLimit, long count, long now) + throws InterruptedException { + return now; + } + }; + } } }; diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java index 89fb5fe7b..a47d6eb4c 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java @@ -27,7 +27,6 @@ import org.jenkinsci.plugins.github.config.GitHubServerConfig; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.kohsuke.github.GHRateLimit; import org.kohsuke.github.GitHub; @@ -160,7 +159,6 @@ private void setupStubs(List scenarios) throws Exception { assertEquals(2, initialRequestCount); } - @Ignore("behavior deliberately modified") @Test public void NoCheckerConfigured() throws Exception { // set up scenarios @@ -351,7 +349,6 @@ public void NoThrottleTestShouldNotThrottle404() throws Exception { * * @author Marc Salles Navarro */ - @Ignore("behavior deliberately modified") @Test public void NoThrottleTestShouldFallbackToThrottleOnOverForGitHubDotCom() throws Exception { GitHubConfiguration.get().setApiRateLimitChecker(ApiRateLimitChecker.ThrottleOnOver); From f62ec0a7d85da58e41e1b71c68bd5d1745c37ecb Mon Sep 17 00:00:00 2001 From: ARUS2023 <145485937+ARUS2023@users.noreply.github.com> Date: Tue, 26 Sep 2023 06:35:01 -0500 Subject: [PATCH 11/37] Removed 1 unnecessary stubbing in GitHubSCMSourceTest.java (#732) --- .../plugins/github_branch_source/GitHubSCMSourceTest.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java index b91212b9f..802cfb2e0 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java @@ -919,10 +919,6 @@ public void testShouldRetrieveTagSCMHeadType() throws Exception { @Issue("JENKINS-65071") public void testShouldRetrieveNullEvent() throws Exception { SCMHeadObserver mockSCMHeadObserver = Mockito.mock(SCMHeadObserver.class); - Mockito.when(mockSCMHeadObserver.getIncludes()) - .thenReturn( - Collections.singleton(new GitHubTagSCMHead("non-existent-tag", System.currentTimeMillis()))); - assertTrue(this.source.shouldRetrieve(mockSCMHeadObserver, null, GitHubTagSCMHead.class)); assertTrue(this.source.shouldRetrieve(mockSCMHeadObserver, null, PullRequestSCMHead.class)); assertTrue(this.source.shouldRetrieve(mockSCMHeadObserver, null, BranchSCMHead.class)); From 86f19ae669ac621ee94a8b63a693de09323da7bb Mon Sep 17 00:00:00 2001 From: Bruno Verachten Date: Mon, 2 Oct 2023 21:14:36 +0200 Subject: [PATCH 12/37] Test with Java 21 (#736) * Add a JDK21 Jenkinsfile for ci.jenkins.io * Update Jenkinsfile --- Jenkinsfile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8d38b971d..9bdbcc7d2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,10 @@ -buildPlugin(useContainerAgent: true, configurations: [ - [platform: 'linux', jdk: 17], - [platform: 'windows', jdk: 11], +/* + See the documentation for more options: + https://github.com/jenkins-infra/pipeline-library/ +*/ +buildPlugin( + useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests + configurations: [ + [platform: 'linux', jdk: 21], + [platform: 'windows', jdk: 17], ]) From 7bec28752f4d250713a28dfe08fff4ebb7e4ee35 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Oct 2023 01:51:23 +0000 Subject: [PATCH 13/37] Bump org.jenkins-ci.plugins:plugin from 4.73 to 4.74 Bumps [org.jenkins-ci.plugins:plugin](https://github.com/jenkinsci/plugin-pom) from 4.73 to 4.74. - [Release notes](https://github.com/jenkinsci/plugin-pom/releases) - [Changelog](https://github.com/jenkinsci/plugin-pom/blob/master/CHANGELOG.md) - [Commits](https://github.com/jenkinsci/plugin-pom/compare/plugin-4.73...plugin-4.74) --- updated-dependencies: - dependency-name: org.jenkins-ci.plugins:plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c7df1d675..f9e3e4c25 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.plugins plugin - 4.73 + 4.74 From 435450a72157914e81f210d935374e9842758399 Mon Sep 17 00:00:00 2001 From: Allan Burdajewicz Date: Mon, 18 Sep 2023 16:34:27 +1000 Subject: [PATCH 14/37] [JENKINS-72030] Add checkbox to enable/disable Avatar retrieval --- .../GitHubSCMNavigator.java | 28 ++++++++++++++++++- .../GitHubSCMNavigator/config.jelly | 3 ++ .../GitHubSCMNavigator/help-enableAvatar.html | 4 +++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/help-enableAvatar.html diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index d2adf273b..e45405921 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -128,6 +128,12 @@ public class GitHubSCMNavigator extends SCMNavigator { @CheckForNull private String credentialsId; /** The behavioural traits to apply. */ + + /** + * Whether to enable the retrieval of the Organization avatar. If false, then the default GitHub logo will be used. + */ + private boolean enableAvatar; + @NonNull private List>> traits; @@ -221,6 +227,7 @@ public class GitHubSCMNavigator extends SCMNavigator { public GitHubSCMNavigator(String repoOwner) { this.repoOwner = StringUtils.defaultString(repoOwner); this.traits = new ArrayList<>(); + this.enableAvatar = false; } /** @@ -302,6 +309,25 @@ public void setCredentialsId(@CheckForNull String credentialsId) { this.credentialsId = Util.fixEmpty(credentialsId); } + /** + * Return if the avatar retrieval is enabled. + * + * @return true is enabled, false otherwise + */ + public boolean isEnableAvatar() { + return enableAvatar; + } + + /** + * Enable retrieval of the organization avatar. + * + * @param enableAvatar true to enable, false to disable + */ + @DataBoundSetter + public void setEnableAvatar(boolean enableAvatar) { + this.enableAvatar = enableAvatar; + } + /** * Gets the name of the owner who's repositories will be navigated. * @@ -1531,7 +1557,7 @@ public List retrieveActions( Connector.lookupScanCredentials((Item) owner, getApiUri(), credentialsId, repoOwner); GitHub hub = Connector.connect(getApiUri(), credentials); Connector.configureLocalRateLimitChecker(listener, hub); - boolean privateMode = determinePrivateMode(apiUri); + boolean privateMode = !enableAvatar || determinePrivateMode(apiUri); try { GHUser u = hub.getUser(getRepoOwner()); String objectUrl = u.getHtmlUrl() == null ? null : u.getHtmlUrl().toExternalForm(); diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/config.jelly b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/config.jelly index 96550402f..0facd637f 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/config.jelly +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/config.jelly @@ -19,6 +19,9 @@ + + + diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/help-enableAvatar.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/help-enableAvatar.html new file mode 100644 index 000000000..3bea92d90 --- /dev/null +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/help-enableAvatar.html @@ -0,0 +1,4 @@ +
+

Whether to use the GitHub Organization or GitHub User Account avatar as icon (only possible if private mode is disabled).

+

Note: this consumes an anonymous call to check if private mode is enabled. Although the result of this check is cached for some time (20 hours by default), this can block operations in some environments. See JENKINS-72030

+
From 7b720fb1e6d40220946a259de0f2808a9e2db946 Mon Sep 17 00:00:00 2001 From: Allan Burdajewicz Date: Fri, 6 Oct 2023 17:46:19 +1000 Subject: [PATCH 15/37] [JENKINS-72030] Adapt and add test --- .../github_branch_source/GitHubSCMNavigatorTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java index 856d087b9..c8e35ad3b 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java @@ -427,6 +427,18 @@ public void appliesFilters() throws Exception { @Test public void fetchActions() throws Exception { + assertThat( + navigator.fetchActions(Mockito.mock(SCMNavigatorOwner.class), null, null), + Matchers.containsInAnyOrder( + Matchers.is( + new ObjectMetadataAction("CloudBeers, Inc.", null, "https://github.com/cloudbeers")), + Matchers.is(new GitHubOrgMetadataAction((String) null)), + Matchers.is(new GitHubLink("icon-github-logo", "https://github.com/cloudbeers")))); + } + + @Test + public void fetchActionsWithAvatar() throws Exception { + navigator.setEnableAvatar(true); assertThat( navigator.fetchActions(Mockito.mock(SCMNavigatorOwner.class), null, null), Matchers.containsInAnyOrder( From 43d790561e2604739e1b39866b8b7eea6da78519 Mon Sep 17 00:00:00 2001 From: Allan Burdajewicz Date: Mon, 9 Oct 2023 12:32:15 +1000 Subject: [PATCH 16/37] [JENKINS-72030] Enable for existing items. Default to disable for new items. --- .../github_branch_source/GitHubSCMNavigator.java | 13 ++++++++----- .../GitHubSCMNavigator/config.jelly | 2 +- .../GitHubSCMNavigatorTest.java | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index e45405921..4f70f44a9 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -132,7 +132,7 @@ public class GitHubSCMNavigator extends SCMNavigator { /** * Whether to enable the retrieval of the Organization avatar. If false, then the default GitHub logo will be used. */ - private boolean enableAvatar; + private Boolean enableAvatar; @NonNull private List>> traits; @@ -227,7 +227,6 @@ public class GitHubSCMNavigator extends SCMNavigator { public GitHubSCMNavigator(String repoOwner) { this.repoOwner = StringUtils.defaultString(repoOwner); this.traits = new ArrayList<>(); - this.enableAvatar = false; } /** @@ -314,7 +313,8 @@ public void setCredentialsId(@CheckForNull String credentialsId) { * * @return true is enabled, false otherwise */ - public boolean isEnableAvatar() { + @CheckForNull + public Boolean getEnableAvatar() { return enableAvatar; } @@ -324,7 +324,7 @@ public boolean isEnableAvatar() { * @param enableAvatar true to enable, false to disable */ @DataBoundSetter - public void setEnableAvatar(boolean enableAvatar) { + public void setEnableAvatar(Boolean enableAvatar) { this.enableAvatar = enableAvatar; } @@ -391,6 +391,9 @@ private Object readResolve() { if (scanCredentialsId != null) { credentialsId = scanCredentialsId; } + if (enableAvatar == null) { + enableAvatar = Boolean.TRUE; + } if (traits == null) { boolean buildOriginBranch = this.buildOriginBranch == null || this.buildOriginBranch; boolean buildOriginBranchWithPR = this.buildOriginBranchWithPR == null || this.buildOriginBranchWithPR; @@ -1557,7 +1560,7 @@ public List retrieveActions( Connector.lookupScanCredentials((Item) owner, getApiUri(), credentialsId, repoOwner); GitHub hub = Connector.connect(getApiUri(), credentials); Connector.configureLocalRateLimitChecker(listener, hub); - boolean privateMode = !enableAvatar || determinePrivateMode(apiUri); + boolean privateMode = !Boolean.TRUE.equals(enableAvatar) || determinePrivateMode(apiUri); try { GHUser u = hub.getUser(getRepoOwner()); String objectUrl = u.getHtmlUrl() == null ? null : u.getHtmlUrl().toExternalForm(); diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/config.jelly b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/config.jelly index 0facd637f..35e97264d 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/config.jelly +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/config.jelly @@ -20,7 +20,7 @@ - + diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java index c8e35ad3b..c5aa822ba 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java @@ -437,8 +437,8 @@ public void fetchActions() throws Exception { } @Test - public void fetchActionsWithAvatar() throws Exception { - navigator.setEnableAvatar(true); + public void fetchActionsWithoutAvatar() throws Exception { + navigator.setEnableAvatar(false); assertThat( navigator.fetchActions(Mockito.mock(SCMNavigatorOwner.class), null, null), Matchers.containsInAnyOrder( From 4a5f00e4468ff8ad6b02069850dafec939ea8f1c Mon Sep 17 00:00:00 2001 From: Allan Burdajewicz Date: Tue, 10 Oct 2023 18:28:03 +1000 Subject: [PATCH 17/37] [JENKINS-72030] Use boolean --- .../plugins/github_branch_source/GitHubSCMNavigator.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index 4f70f44a9..2f6bc5ad3 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -313,9 +313,10 @@ public void setCredentialsId(@CheckForNull String credentialsId) { * * @return true is enabled, false otherwise */ - @CheckForNull - public Boolean getEnableAvatar() { - return enableAvatar; + @NonNull + @SuppressWarnings("unused") // stapler + public boolean getEnableAvatar() { + return Boolean.TRUE.equals(enableAvatar); } /** @@ -324,7 +325,7 @@ public Boolean getEnableAvatar() { * @param enableAvatar true to enable, false to disable */ @DataBoundSetter - public void setEnableAvatar(Boolean enableAvatar) { + public void setEnableAvatar(boolean enableAvatar) { this.enableAvatar = enableAvatar; } From bfd5eabf58931f7ae2369f4a9d4859c093a5905e Mon Sep 17 00:00:00 2001 From: Allan Burdajewicz Date: Wed, 11 Oct 2023 10:17:50 +1000 Subject: [PATCH 18/37] [JENKINS-72030] Use getEnableAvatar() Co-authored-by: Jesse Glick --- .../plugins/github_branch_source/GitHubSCMNavigator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index 2f6bc5ad3..d2504df73 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -1561,7 +1561,7 @@ public List retrieveActions( Connector.lookupScanCredentials((Item) owner, getApiUri(), credentialsId, repoOwner); GitHub hub = Connector.connect(getApiUri(), credentials); Connector.configureLocalRateLimitChecker(listener, hub); - boolean privateMode = !Boolean.TRUE.equals(enableAvatar) || determinePrivateMode(apiUri); + boolean privateMode = !getEnableAvatar() || determinePrivateMode(apiUri); try { GHUser u = hub.getUser(getRepoOwner()); String objectUrl = u.getHtmlUrl() == null ? null : u.getHtmlUrl().toExternalForm(); From 60a81173f43a4f8ffdfe4fb1d9076646a9ec6278 Mon Sep 17 00:00:00 2001 From: ARUS2023 <145485937+ARUS2023@users.noreply.github.com> Date: Thu, 12 Oct 2023 17:25:28 -0500 Subject: [PATCH 19/37] Removed 1 unnecessary stubbing in GithubSCMSourceBranchesTest.java (#733) * Removed 1 unnecessary stubbing in GithubSCMSourceBranchesTest.java * Fixed the test in GithubSCMSourceBranchesTest.java --- .../github_branch_source/GithubSCMSourceBranchesTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubSCMSourceBranchesTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubSCMSourceBranchesTest.java index 87b1d29be..d34b2a321 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubSCMSourceBranchesTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubSCMSourceBranchesTest.java @@ -80,14 +80,14 @@ public void testThrownErrorSingleBranchException() throws IOException { context.wantBranches(true); GitHubSCMSourceRequest request = context.newRequest(new GitHubSCMSource("cloudbeers", "yolo", null, false), null); - Mockito.doThrow(e).when(repoSpy).getRef("branches/existent-branch"); + Mockito.doThrow(e).when(repoSpy).getBranch("existent-branch"); // Expected: This will throw an error when requesting a branch try { Iterator branches = new GitHubSCMSource.LazyBranches(request, repoSpy).iterator(); fail("This should throw an exception"); } catch (Error error) { // Error is expected here so this is "success" - assertEquals("Bad Branch Request", e.getMessage()); + assertEquals("Bad Branch Request", error.getMessage()); } } From 480b5d0364eb4e10d6fc72f5fef669f331a050f5 Mon Sep 17 00:00:00 2001 From: Allan Burdajewicz Date: Fri, 13 Oct 2023 11:02:04 +1000 Subject: [PATCH 20/37] [JENKINS-72030] Fix test --- .../plugins/github_branch_source/GitHubSCMNavigatorTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java index c5aa822ba..c8e35ad3b 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java @@ -437,8 +437,8 @@ public void fetchActions() throws Exception { } @Test - public void fetchActionsWithoutAvatar() throws Exception { - navigator.setEnableAvatar(false); + public void fetchActionsWithAvatar() throws Exception { + navigator.setEnableAvatar(true); assertThat( navigator.fetchActions(Mockito.mock(SCMNavigatorOwner.class), null, null), Matchers.containsInAnyOrder( From 8cc08abafa899bb93c96ff70fba07e4943b7bfc8 Mon Sep 17 00:00:00 2001 From: Allan Burdajewicz Date: Tue, 7 Nov 2023 17:11:51 +1000 Subject: [PATCH 21/37] [JENKINS-72030] getEnableAvater -> isEnableAvatar --- .../plugins/github_branch_source/GitHubSCMNavigator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index d2504df73..4cb595e13 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -315,7 +315,7 @@ public void setCredentialsId(@CheckForNull String credentialsId) { */ @NonNull @SuppressWarnings("unused") // stapler - public boolean getEnableAvatar() { + public boolean isEnableAvatar() { return Boolean.TRUE.equals(enableAvatar); } @@ -1561,7 +1561,7 @@ public List retrieveActions( Connector.lookupScanCredentials((Item) owner, getApiUri(), credentialsId, repoOwner); GitHub hub = Connector.connect(getApiUri(), credentials); Connector.configureLocalRateLimitChecker(listener, hub); - boolean privateMode = !getEnableAvatar() || determinePrivateMode(apiUri); + boolean privateMode = !isEnableAvatar() || determinePrivateMode(apiUri); try { GHUser u = hub.getUser(getRepoOwner()); String objectUrl = u.getHtmlUrl() == null ? null : u.getHtmlUrl().toExternalForm(); From 4c250951d4602ef4cc33dea61377834aa61fdccb Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 15 Nov 2023 09:52:11 +1000 Subject: [PATCH 22/37] Do not enforce GitHub app to comes from the same org as the repo org. The GH app can come from another org as log as it is installed in the org with the target git repo there is no security issue (#744) Signed-off-by: Olivier Lamy --- .../plugins/github_branch_source/GitHubAppCredentials.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java index c4f45cf6b..4eead6687 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java @@ -326,9 +326,6 @@ public String getUsername() { @NonNull public synchronized GitHubAppCredentials withOwner(@NonNull String owner) { if (this.owner != null) { - if (!owner.equals(this.owner)) { - throw new IllegalArgumentException("Owner mismatch: " + this.owner + " vs. " + owner); - } return this; } if (byOwner == null) { From 856b6c3a0a47387797459e47041d98833f42d243 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Oct 2023 01:42:18 +0000 Subject: [PATCH 23/37] Bump org.jenkins-ci.plugins:plugin from 4.74 to 4.75 Bumps [org.jenkins-ci.plugins:plugin](https://github.com/jenkinsci/plugin-pom) from 4.74 to 4.75. - [Release notes](https://github.com/jenkinsci/plugin-pom/releases) - [Changelog](https://github.com/jenkinsci/plugin-pom/blob/master/CHANGELOG.md) - [Commits](https://github.com/jenkinsci/plugin-pom/compare/plugin-4.74...plugin-4.75) --- updated-dependencies: - dependency-name: org.jenkins-ci.plugins:plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f9e3e4c25..a6f588703 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.plugins plugin - 4.74 + 4.75 From 6b61a1dc35b4f5f32871d3c585036d64f2e4476d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Nov 2023 23:53:15 +0000 Subject: [PATCH 24/37] Bump io.jenkins.tools.bom:bom-2.387.x Bumps [io.jenkins.tools.bom:bom-2.387.x](https://github.com/jenkinsci/bom) from 2378.v3e03930028f2 to 2543.vfb_1a_5fb_9496d. - [Release notes](https://github.com/jenkinsci/bom/releases) - [Commits](https://github.com/jenkinsci/bom/commits) --- updated-dependencies: - dependency-name: io.jenkins.tools.bom:bom-2.387.x dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a6f588703..a5019507c 100644 --- a/pom.xml +++ b/pom.xml @@ -43,7 +43,7 @@ io.jenkins.tools.bom bom-2.387.x - 2378.v3e03930028f2 + 2543.vfb_1a_5fb_9496d pom import From 901162c0335841d408b737e9275f798350c8da02 Mon Sep 17 00:00:00 2001 From: James Nord Date: Wed, 15 Nov 2023 12:04:47 +0000 Subject: [PATCH 25/37] Revert "Do not enforce GitHub app to comes from the same org as the repo org. The GH app can come from another org as log as it is installed in the org with the target git repo there is no security issue (#744)" This reverts commit 4c250951d4602ef4cc33dea61377834aa61fdccb. --- .../plugins/github_branch_source/GitHubAppCredentials.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java index 4eead6687..c4f45cf6b 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java @@ -326,6 +326,9 @@ public String getUsername() { @NonNull public synchronized GitHubAppCredentials withOwner(@NonNull String owner) { if (this.owner != null) { + if (!owner.equals(this.owner)) { + throw new IllegalArgumentException("Owner mismatch: " + this.owner + " vs. " + owner); + } return this; } if (byOwner == null) { From 90e17c48a6accf2a1a0f189131607261c84e304a Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Thu, 16 Nov 2023 13:58:44 +0100 Subject: [PATCH 26/37] [JENKINS-72330] Fix test connection in case a GitHub App has more than 1 installation (#748) * Add additional check when testing the connection if the configured GitHub App has more than 1 installation, in which case the owner of the first installation is used to test the connection. Clarify the documentation of the owner field that it is not required unless you wanna restrict to a single organization. * Apply spotless complaints. --- .../GitHubAppCredentials.java | 17 ++++++++++++++++- .../GitHubAppCredentials/help-owner.html | 3 ++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java index c4f45cf6b..386c86f20 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java @@ -123,7 +123,7 @@ public Secret getPrivateKey() { } /** - * Owner of this installation, i.e. a user or organisation, used to differeniate app installations + * Owner of this installation, i.e. a user or organisation, used to differentiate app installations * when the app is installed to multiple organisations / users. * *

If this is null then call listInstallations and if there's only one in the list then use @@ -692,6 +692,21 @@ public FormValidation doTestConnection( gitHubAppCredential.setOwner(owner); try { + // If no owner is specified, check if the app has multiple installations. + if (owner == null || owner.isEmpty()) { + GitHub gitHubApp = TokenProvider.createTokenRefreshGitHub( + appID, privateKey, gitHubAppCredential.actualApiUri()); + List appInstallations = + gitHubApp.getApp().listInstallations().toList(); + if (appInstallations.size() > 1) { + // Just pick the owner of the first installation, so we have a valid + // owner to create an access token for testing the connection. + String anyInstallationOwner = + appInstallations.get(0).getAccount().getLogin(); + gitHubAppCredential.setOwner(anyInstallationOwner); + } + } + GitHub connect = Connector.connect(apiUri, gitHubAppCredential); try { return FormValidation.ok("Success, Remaining rate limit: " diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-owner.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-owner.html index 86a279f3f..110fbf25f 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-owner.html +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-owner.html @@ -1,6 +1,7 @@

The organisation or user that this app is to be used for. - Only required if this app is installed to multiple organisations. + Only required if this app is installed to multiple organisations and connections + should be restricted to a single organisation. May be omitted in case credentials are used from GitHub multibranch projects (in that case the account is determined from the branch source where the credentials are used).

From c201a0235d808113e431958574b70a0d9721a949 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Mon, 27 Nov 2023 01:07:30 -0800 Subject: [PATCH 27/37] Test changes to support github-api 1.318 (#749) * Update pom.xml with 1.318 * Fix tests * Revert hard coded github-api version --- .../ApiRateLimitCheckerTest.java | 57 +++++++++++++++++-- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java index a47d6eb4c..c1770c8ff 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java @@ -108,6 +108,11 @@ private void setupStubs(List scenarios) throws Exception { githubApi.stubFor(get(urlEqualTo("/meta")) .willReturn(aResponse().withStatus(200).withBody("{\"verifiable_password_authentication\": false}"))); + githubApi.stubFor(get(urlEqualTo("/licenses/MIT")) + .willReturn(aResponse() + .withStatus(200) + .withBody("{" + "\"key\": \"mit\"," + "\"name\": \"MIT License\"}"))); + githubApi.stubFor(get(urlEqualTo("/")) .willReturn(aResponse() .withStatus(200) @@ -174,15 +179,15 @@ public void NoCheckerConfigured() throws Exception { setupStubs(scenarios); GitHubConfiguration.get().setApiRateLimitChecker(ApiRateLimitChecker.ThrottleForNormalize); - github.getMeta(); + github.getLicense("MIT"); ApiRateLimitChecker.resetLocalChecker(); GitHubConfiguration.get().setApiRateLimitChecker(ApiRateLimitChecker.ThrottleOnOver); - github.getMeta(); + github.getLicense("MIT"); ApiRateLimitChecker.resetLocalChecker(); GitHubConfiguration.get().setApiRateLimitChecker(ApiRateLimitChecker.NoThrottle); - github.getMeta(); + github.getLicense("MIT"); assertEquals(3, countOfOutputLinesContaining("LocalChecker for rate limit was not set for this thread.")); assertEquals(3, countOfOutputLinesContaining("with API URL 'https://api.github.com'")); @@ -249,7 +254,7 @@ public void ThrottleOnOverTestWithQuota() throws Exception { // Given a full rate limit quota, then we expect no throttling // Also only 1 call to get rate limit, since rate limit record is valid for a while for (int i = 0; i < 100; i++) { - github.getMeta(); + github.getLicense("MIT"); } assertEquals(0, countOfOutputLinesContaining("Sleeping")); @@ -277,7 +282,7 @@ public void ThrottleOnNormalizeTestWithQuota() throws Exception { // Given a full rate limit quota, then we expect no throttling for (int i = 0; i < 100; i++) { - github.getMeta(); + github.getLicense("MIT"); } assertEquals(0, countOfOutputLinesContaining("Sleeping")); @@ -303,7 +308,7 @@ public void NoThrottleTestShouldNotThrottle() throws Exception { ApiRateLimitChecker.configureThreadLocalChecker(listener, github); for (int i = 0; i < 100; i++) { - github.getMeta(); + github.getLicense("MIT"); } // there should be no output @@ -331,6 +336,8 @@ public void NoThrottleTestShouldNotThrottle404() throws Exception { ApiRateLimitChecker.configureThreadLocalChecker(listener, github); + // sanity cached to limit queries to once per second + Thread.sleep(1001); github.getMeta(); // The core should be unknown, but different from initial @@ -368,6 +375,8 @@ public void NoThrottleTestShouldFallbackToThrottleOnOverForGitHubDotCom() throws ApiRateLimitChecker.configureThreadLocalChecker(listener, spy); + // sanity cached to limit queries to once per second + Thread.sleep(1001); spy.getMeta(); assertEquals(1, countOfOutputLinesContaining("ThrottleOnOver will be used instead")); @@ -408,6 +417,8 @@ public void ThrottleOnOverTest() throws Exception { // does not happen until under buffer for (int i = 0; i < 11; i++) { assertFalse(currentChecker.checkRateLimit(github.getRateLimit().getCore(), 0)); + // sanity cached to limit queries to once per second + Thread.sleep(1001); } // should be no output @@ -418,10 +429,14 @@ public void ThrottleOnOverTest() throws Exception { // check rate limit to hit the next 9 scenarios for (int i = 0; i < 10; i++) { assertTrue(currentChecker.checkRateLimit(github.getRateLimit().getCore(), i)); + // sanity cached to limit queries to once per second + Thread.sleep(1001); } // This simulates the waiting until refreshed currentChecker.resetExpiration(); assertFalse(currentChecker.checkRateLimit(github.getRateLimit().getCore(), 10)); + // sanity cached to limit queries to once per second + Thread.sleep(1001); // output for all the throttled scenarios. Sleeps normally on the first and then the `notify` // hits the next 9 @@ -492,6 +507,8 @@ public void ThrottleForNormalizeTestWithinIdeal() throws Exception { // First check will not say under budget (add counts) github.getMeta(); + // sanity cached to limit queries to once per second + Thread.sleep(1001); assertEquals(4, getRequestCount(githubApi)); // Feature removed, no output for under budget @@ -503,6 +520,8 @@ public void ThrottleForNormalizeTestWithinIdeal() throws Exception { // check rate limit to hit the next 6 scenarios for (int i = 0; i < 6; i++) { assertTrue(currentChecker.checkRateLimit(github.getRateLimit().getCore(), i)); + // sanity cached to limit queries to once per second + Thread.sleep(1001); } assertEquals(initialRequestCount + 5, handler.getView().size()); @@ -510,6 +529,8 @@ public void ThrottleForNormalizeTestWithinIdeal() throws Exception { // This simulates the waiting until refreshed currentChecker.resetExpiration(); assertFalse(currentChecker.checkRateLimit(github.getRateLimit().getCore(), 9)); + // sanity cached to limit queries to once per second + Thread.sleep(1001); assertEquals(initialRequestCount + 9, getRequestCount(githubApi)); // Functionality removed @@ -557,11 +578,18 @@ public void NormalizeThrottleWithBurnedBuffer() throws Exception { ApiRateLimitChecker.LocalChecker currentChecker = ApiRateLimitChecker.getLocalChecker(); assertTrue(currentChecker.checkRateLimit(github.getRateLimit().getCore(), 0)); + // sanity cached to limit queries to once per second + Thread.sleep(1001); assertTrue(currentChecker.checkRateLimit(github.getRateLimit().getCore(), 1)); + Thread.sleep(1001); assertTrue(currentChecker.checkRateLimit(github.getRateLimit().getCore(), 2)); + Thread.sleep(1001); assertTrue(currentChecker.checkRateLimit(github.getRateLimit().getCore(), 3)); + Thread.sleep(1001); assertTrue(currentChecker.checkRateLimit(github.getRateLimit().getCore(), 4)); + Thread.sleep(1001); assertTrue(currentChecker.checkRateLimit(github.getRateLimit().getCore(), 5)); + Thread.sleep(1001); // Expect a triggered throttle for normalize // GitHubRateLimitChecker add 1 second to notification loop, this hides the entropy value @@ -618,6 +646,8 @@ public void OnOverThrottleTimingRateLimitCheck() throws Exception { github.getRateLimit(); // calls rateLimit() for first loop so we have to getRateLimit() for each loop github.getMeta(); + // sanity cached to limit queries to once per second + Thread.sleep(1001); } // (rate_limit + meta) x 6 @@ -631,10 +661,14 @@ public void OnOverThrottleTimingRateLimitCheck() throws Exception { // check rate limit to hit the next 5 scenarios for (int i = 0; i < 5; i++) { assertTrue(currentChecker.checkRateLimit(github.getRateLimit().getCore(), i)); + // sanity cached to limit queries to once per second + Thread.sleep(1001); } // This simulates the waiting until refreshed currentChecker.resetExpiration(); assertFalse(currentChecker.checkRateLimit(github.getRateLimit().getCore(), 5)); + // sanity cached to limit queries to once per second + Thread.sleep(1001); assertEquals(initialRequestCount + 18, getRequestCount(githubApi)); @@ -689,6 +723,8 @@ public void NormalizeThrottleTimingRateLimitCheck() throws Exception { ApiRateLimitChecker.configureThreadLocalChecker(listener, github); github.getMeta(); + // sanity cached to limit queries to once per second + Thread.sleep(1001); // start timing long start = System.currentTimeMillis(); @@ -697,11 +733,16 @@ public void NormalizeThrottleTimingRateLimitCheck() throws Exception { ApiRateLimitChecker.LocalChecker currentChecker = ApiRateLimitChecker.getLocalChecker(); assertTrue(currentChecker.checkRateLimit(github.getRateLimit().getCore(), 0)); + // sanity cached to limit queries to once per second + Thread.sleep(1001); assertTrue(currentChecker.checkRateLimit(github.getRateLimit().getCore(), 1)); + Thread.sleep(1001); assertTrue(currentChecker.checkRateLimit(github.getRateLimit().getCore(), 2)); + Thread.sleep(1001); // This simulates the waiting until refreshed currentChecker.resetExpiration(); assertFalse(currentChecker.checkRateLimit(github.getRateLimit().getCore(), 3)); + Thread.sleep(1001); assertEquals(initialRequestCount + 6, getRequestCount(githubApi)); @@ -777,6 +818,8 @@ public void NormalizeExpectedIdealOverTime() throws Exception { } // calls rateLimit() for first loop so we have to getRateLimit() for each loop github.getMeta(); + // sanity cached to limit queries to once per second + Thread.sleep(1001); } // rate_limit + meta x 12 @@ -829,6 +872,8 @@ public void OnOverExpectedIdealOverTime() throws Exception { } // calls rateLimit() for first loop so we have to getRateLimit() for each loop github.getMeta(); + // sanity cached to limit queries to once per second + Thread.sleep(1001); } assertEquals(12, getRequestCount(githubApi)); From 7262e35330910403fab97ae2848a6fb708649c8a Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Fri, 1 Dec 2023 14:44:29 -0500 Subject: [PATCH 28/37] [JENKINS-66675] Do not treat `appID` as a secret --- .../plugins/github_branch_source/GitHubAppCredentials.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java index c4f45cf6b..f062de532 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java @@ -323,6 +323,11 @@ public String getUsername() { return appID; } + @Override + public boolean isUsernameSecret() { + return false; + } + @NonNull public synchronized GitHubAppCredentials withOwner(@NonNull String owner) { if (this.owner != null) { From cdbd136f3b25b963c346a0dced11263bb2e04176 Mon Sep 17 00:00:00 2001 From: Michael Tughan Date: Fri, 8 Dec 2023 15:29:41 -0500 Subject: [PATCH 29/37] [JENKINS-60874] Configuring ForkPullRequestDiscoveryTrait using Job DSL (#752) JENKINS-26535 describes an issue where wildcards in generics aren't handled well and result in the inability to configure classes that use wildcards in Job DSL, such as the SCMHeadAuthority class used for the forked PR trust policy. To work around this issue, create a new abstract class named GitHubForkTrustPolicy which extends the necessary SCMHeadAuthority superclass with its proper generics and use it in the constructor instead. Update all the trust policies to extend from this abstract class so they can be used. Fixes JENKINS-60874. --- .../ForkPullRequestDiscoveryTrait.java | 30 ++++++++++++------- .../ForkPullRequestDiscoveryTrait2Test.java | 6 +--- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait.java index f7bf3e7d0..495380b21 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait.java @@ -39,7 +39,6 @@ import jenkins.scm.api.trait.SCMHeadAuthority; import jenkins.scm.api.trait.SCMHeadAuthorityDescriptor; import jenkins.scm.api.trait.SCMSourceContext; -import jenkins.scm.api.trait.SCMSourceRequest; import jenkins.scm.api.trait.SCMSourceTrait; import jenkins.scm.api.trait.SCMSourceTraitDescriptor; import jenkins.scm.impl.ChangeRequestSCMHeadCategory; @@ -83,6 +82,12 @@ public class ForkPullRequestDiscoveryTrait extends SCMSourceTrait { * @param trust the authority to use. */ @DataBoundConstructor + public ForkPullRequestDiscoveryTrait(int strategyId, @NonNull GitHubForkTrustPolicy trust) { + this.strategyId = strategyId; + this.trust = trust; + } + + @Deprecated public ForkPullRequestDiscoveryTrait( int strategyId, @NonNull @@ -236,9 +241,15 @@ public List getTrustDescriptors() { } } + /** Trust policy for forked pull requests. + *

+ * This reduces generics in the DataBoundConstructor signature as a workaround for JENKINS-26535. + */ + public abstract static class GitHubForkTrustPolicy + extends SCMHeadAuthority {} + /** An {@link SCMHeadAuthority} that trusts nothing. */ - public static class TrustNobody - extends SCMHeadAuthority { + public static class TrustNobody extends GitHubForkTrustPolicy { /** Constructor. */ @DataBoundConstructor @@ -246,7 +257,7 @@ public TrustNobody() {} /** {@inheritDoc} */ @Override - public boolean checkTrusted(@NonNull SCMSourceRequest request, @NonNull PullRequestSCMHead head) { + public boolean checkTrusted(@NonNull GitHubSCMSourceRequest request, @NonNull PullRequestSCMHead head) { return false; } @@ -270,8 +281,7 @@ public boolean isApplicableToOrigin(@NonNull Class orig } /** An {@link SCMHeadAuthority} that trusts contributors to the repository. */ - public static class TrustContributors - extends SCMHeadAuthority { + public static class TrustContributors extends GitHubForkTrustPolicy { /** Constructor. */ @DataBoundConstructor public TrustContributors() {} @@ -303,8 +313,7 @@ public boolean isApplicableToOrigin(@NonNull Class orig } /** An {@link SCMHeadAuthority} that trusts those with write permission to the repository. */ - public static class TrustPermission - extends SCMHeadAuthority { + public static class TrustPermission extends GitHubForkTrustPolicy { /** Constructor. */ @DataBoundConstructor @@ -347,15 +356,14 @@ public boolean isApplicableToOrigin(@NonNull Class orig } /** An {@link SCMHeadAuthority} that trusts everyone. */ - public static class TrustEveryone - extends SCMHeadAuthority { + public static class TrustEveryone extends GitHubForkTrustPolicy { /** Constructor. */ @DataBoundConstructor public TrustEveryone() {} /** {@inheritDoc} */ @Override - protected boolean checkTrusted(@NonNull SCMSourceRequest request, @NonNull PullRequestSCMHead head) { + protected boolean checkTrusted(@NonNull GitHubSCMSourceRequest request, @NonNull PullRequestSCMHead head) { return true; } diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait2Test.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait2Test.java index 91ef0c4d5..cb61162c6 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait2Test.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait2Test.java @@ -28,9 +28,6 @@ import java.util.Collections; import java.util.List; import jenkins.branch.BranchSource; -import jenkins.scm.api.SCMRevision; -import jenkins.scm.api.mixin.ChangeRequestSCMHead2; -import jenkins.scm.api.trait.SCMHeadAuthority; import jenkins.scm.api.trait.SCMSourceTrait; import org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject; import org.junit.Ignore; @@ -69,8 +66,7 @@ public void configRoundtripWithRawUrl() throws Exception { private void assertRoundTrip( WorkflowMultiBranchProject p, - SCMHeadAuthority - trust, + ForkPullRequestDiscoveryTrait.GitHubForkTrustPolicy trust, boolean configuredByUrl) throws Exception { From 9ebc964e50bb7d3bcacbfa9d5def525dd3aca7f0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Dec 2023 14:29:39 -0500 Subject: [PATCH 30/37] Bump org.jenkins-ci.plugins:plugin from 4.75 to 4.76 (#753) Bumps [org.jenkins-ci.plugins:plugin](https://github.com/jenkinsci/plugin-pom) from 4.75 to 4.76. - [Release notes](https://github.com/jenkinsci/plugin-pom/releases) - [Changelog](https://github.com/jenkinsci/plugin-pom/blob/master/CHANGELOG.md) - [Commits](https://github.com/jenkinsci/plugin-pom/compare/plugin-4.75...plugin-4.76) --- updated-dependencies: - dependency-name: org.jenkins-ci.plugins:plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a5019507c..d51d67532 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.plugins plugin - 4.75 + 4.76 From 2e5c57acedf6e72cef5b54d55cad144d8fbac629 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Wed, 13 Dec 2023 13:04:51 -0500 Subject: [PATCH 31/37] `GitHubSCMSourceTraitsTest` fix for PCT --- .../GitHubSCMSourceTraitsTest.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTraitsTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTraitsTest.java index 9454ddcdf..2d3e24d2a 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTraitsTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTraitsTest.java @@ -69,12 +69,6 @@ public void given__configuredInstance__when__uninstantiating__then__deprecatedFi recreated.setIncludes("i*"); recreated.setExcludes("production"); recreated.setScanCredentialsId("foo"); - String trust; - if (r.jenkins.getPlugin("gitlab-branch-source") != null) { - trust = "org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait$TrustPermission"; - } else { - trust = "TrustPermission"; - } String originTrait; String forkTrait; if (r.jenkins.getPlugin("cloudbees-bitbucket-branch-source") != null) { @@ -96,9 +90,7 @@ public void given__configuredInstance__when__uninstantiating__then__deprecatedFi + "@gitHubPullRequestDiscovery$" + originTrait + "(strategyId=1), " + "@gitHubForkDiscovery$" + forkTrait + "(" + "strategyId=2," - + "trust=@gitHubTrustPermissions$" - + trust - + "()), " + + "trust=@gitHubTrustPermissions$TrustPermission()), " + "@headWildcardFilter$WildcardSCMHeadFilterTrait(excludes=production,includes=i*)])")); } From 2cfdf198ad7f48e888dbc221d2a55004c30e758e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Jan 2024 20:16:19 +0000 Subject: [PATCH 32/37] Bump org.jenkins-ci.plugins:plugin from 4.76 to 4.77 (#756) Bumps [org.jenkins-ci.plugins:plugin](https://github.com/jenkinsci/plugin-pom) from 4.76 to 4.77. - [Release notes](https://github.com/jenkinsci/plugin-pom/releases) - [Changelog](https://github.com/jenkinsci/plugin-pom/blob/master/CHANGELOG.md) - [Commits](https://github.com/jenkinsci/plugin-pom/compare/plugin-4.76...plugin-4.77) --- updated-dependencies: - dependency-name: org.jenkins-ci.plugins:plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d51d67532..244ff4fc8 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.plugins plugin - 4.76 + 4.77 From 746150a9d8ca53069b6077eee3bf7cfea20187eb Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Wed, 17 Jan 2024 16:12:15 +0100 Subject: [PATCH 33/37] Fix naming of unstable status. Unstable build can have several reasons: - failing tests - uncovered lines - SpotBugs warnings --- .../jenkinsci/plugins/github_branch_source/Messages.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties b/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties index 72a66d1fe..f069b3a68 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties @@ -13,7 +13,7 @@ ForkPullRequestDiscoveryTrait.nobodyDisplayName=Nobody GitHubBranchFilter.DisplayName=GitHub Branch Jobs Only GitHubBuildStatusNotification.CommitStatus.Good=This commit looks good -GitHubBuildStatusNotification.CommitStatus.Unstable=This commit has test failures +GitHubBuildStatusNotification.CommitStatus.Unstable=This commit has failing tests or missing quality gates GitHubBuildStatusNotification.CommitStatus.Failure=This commit cannot be built GitHubBuildStatusNotification.CommitStatus.Aborted=The build of this commit was aborted GitHubBuildStatusNotification.CommitStatus.Other=Something is wrong with the build of this commit From c791c1de675081ae9537210851931b4759c370dd Mon Sep 17 00:00:00 2001 From: Ullrich Hafner Date: Wed, 17 Jan 2024 17:26:25 +0100 Subject: [PATCH 34/37] Improve naming of unstable status Co-authored-by: Jesse Glick --- .../jenkinsci/plugins/github_branch_source/Messages.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties b/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties index f069b3a68..cd647028e 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties @@ -13,7 +13,7 @@ ForkPullRequestDiscoveryTrait.nobodyDisplayName=Nobody GitHubBranchFilter.DisplayName=GitHub Branch Jobs Only GitHubBuildStatusNotification.CommitStatus.Good=This commit looks good -GitHubBuildStatusNotification.CommitStatus.Unstable=This commit has failing tests or missing quality gates +GitHubBuildStatusNotification.CommitStatus.Unstable=This commit failed tests or other validations GitHubBuildStatusNotification.CommitStatus.Failure=This commit cannot be built GitHubBuildStatusNotification.CommitStatus.Aborted=The build of this commit was aborted GitHubBuildStatusNotification.CommitStatus.Other=Something is wrong with the build of this commit From a69edad018d49608010916d5b5f664ef0bc138f3 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Wed, 17 Jan 2024 16:02:13 -0800 Subject: [PATCH 35/37] Forward compatibility with Guice 7 (#758) --- pom.xml | 6 +++--- .../plugins/github_branch_source/GitHubSCMNavigator.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 244ff4fc8..a8954ca86 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ 999999-SNAPSHOT jenkinsci/${project.artifactId}-plugin 2.2.0 - 2.387.3 + 2.414.3 true false @@ -42,8 +42,8 @@ io.jenkins.tools.bom - bom-2.387.x - 2543.vfb_1a_5fb_9496d + bom-2.414.x + 2718.v7e8a_d43b_3f0b_ pom import diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index 4cb595e13..48e36db8e 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -48,6 +48,7 @@ import hudson.model.TaskListener; import hudson.util.FormValidation; import hudson.util.ListBoxModel; +import jakarta.inject.Inject; import java.io.FileNotFoundException; import java.io.IOException; import java.net.MalformedURLException; @@ -62,7 +63,6 @@ import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; -import javax.inject.Inject; import jenkins.model.Jenkins; import jenkins.plugins.git.traits.GitBrowserSCMSourceTrait; import jenkins.scm.api.SCMNavigator; From a223cd139ea5f946b612c7195d29d7e292f1a275 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Wed, 17 Jan 2024 19:04:47 -0500 Subject: [PATCH 36/37] Gratuitous use of Guice --- .../plugins/github_branch_source/GitHubSCMNavigator.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index 48e36db8e..7c135b679 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -38,6 +38,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.AbortException; import hudson.Extension; +import hudson.ExtensionList; import hudson.RestrictedSince; import hudson.Util; import hudson.console.HyperlinkNote; @@ -48,7 +49,6 @@ import hudson.model.TaskListener; import hudson.util.FormValidation; import hudson.util.ListBoxModel; -import jakarta.inject.Inject; import java.io.FileNotFoundException; import java.io.IOException; import java.net.MalformedURLException; @@ -1716,9 +1716,6 @@ public static class DescriptorImpl extends SCMNavigatorDescriptor implements Ico @RestrictedSince("2.2.0") public static final boolean defaultBuildForkPRHead = false; - @Inject - private GitHubSCMSource.DescriptorImpl delegate; - /** {@inheritDoc} */ @Override public String getPronoun() { @@ -1894,7 +1891,8 @@ public boolean test(SCMTraitDescriptor scmTraitDescriptor) { @SuppressWarnings("unused") // jelly @NonNull public List>> getTraitsDefaults() { - return new ArrayList<>(delegate.getTraitsDefaults()); + return new ArrayList<>(ExtensionList.lookupSingleton(GitHubSCMSource.DescriptorImpl.class) + .getTraitsDefaults()); } static { From f92428e8ee8b49bac59f5992ee7119e5f115503b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Mar 2024 12:00:02 -0500 Subject: [PATCH 37/37] Bump org.jenkins-ci.plugins:plugin from 4.77 to 4.79 (#769) Bumps [org.jenkins-ci.plugins:plugin](https://github.com/jenkinsci/plugin-pom) from 4.77 to 4.79. - [Release notes](https://github.com/jenkinsci/plugin-pom/releases) - [Changelog](https://github.com/jenkinsci/plugin-pom/blob/master/CHANGELOG.md) - [Commits](https://github.com/jenkinsci/plugin-pom/compare/plugin-4.77...plugin-4.79) --- updated-dependencies: - dependency-name: org.jenkins-ci.plugins:plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a8954ca86..3c0e00275 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.plugins plugin - 4.77 + 4.79