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
[JENKINS-60874] Configuring ForkPullRequestDiscoveryTrait using Job DSL #752
Conversation
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.
9435d61
to
cd793ab
Compare
yes! |
@jenkinsci/github-branch-source-plugin-developers, is there anything else being waited for here? Or can this be merged? |
Time to release? Thank you! |
unfortunately there is a failure in the master branch, that is preventing an automatic release from happening |
I triggered https://ci.jenkins.io/job/Plugins/job/github-branch-source-plugin/job/master/449/ (and @car-roll you should have been able to do the same). |
@jglick that's what I thought too, but I didn't see any rebuild options on CI |
@car-roll not in CI, in GitHub. Navigate to the trunk commit with a build failure, select the failed check, and Re-run from there. |
Breaks PCT (Plugin Compatibility Tester) when
The problem can be reproduced with diff --git a/pom.xml b/pom.xml
index d51d675..57f6a34 100644
--- a/pom.xml
+++ b/pom.xml
@@ -95,6 +95,11 @@
<artifactId>test-harness</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>io.jenkins.plugins</groupId>
+ <artifactId>gitlab-branch-source</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>pipeline-groovy-lib</artifactId> Suggest the following patch: 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 9454ddc..2d3e24d 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 class GitHubSCMSourceTraitsTest {
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 class GitHubSCMSourceTraitsTest {
+ "@gitHubPullRequestDiscovery$" + originTrait + "(strategyId=1), "
+ "@gitHubForkDiscovery$" + forkTrait + "("
+ "strategyId=2,"
- + "trust=@gitHubTrustPermissions$"
- + trust
- + "()), "
+ + "trust=@gitHubTrustPermissions$TrustPermission()), "
+ "@headWildcardFilter$WildcardSCMHeadFilterTrait(excludes=production,includes=i*)])"));
} |
Description
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.
Example use:
Fixes JENKINS-60874.
Submitter checklist
Reviewer checklist
Documentation changes
Link to jenkins.io PR, or an explanation for why no doc changes are neededThis will be discovered and exposed through the Job DSL API viewer.
Users/aliases to notify