3939import jenkins .scm .api .trait .SCMHeadAuthority ;
4040import jenkins .scm .api .trait .SCMHeadAuthorityDescriptor ;
4141import jenkins .scm .api .trait .SCMSourceContext ;
42- import jenkins .scm .api .trait .SCMSourceRequest ;
4342import jenkins .scm .api .trait .SCMSourceTrait ;
4443import jenkins .scm .api .trait .SCMSourceTraitDescriptor ;
4544import jenkins .scm .impl .ChangeRequestSCMHeadCategory ;
@@ -72,6 +71,13 @@ public class ForkPullRequestDiscoveryTrait extends SCMSourceTrait {
7271 * @param trust the authority to use.
7372 */
7473 @ DataBoundConstructor
74+ public ForkPullRequestDiscoveryTrait (int strategyId ,
75+ @ NonNull BitbucketForkTrustPolicy trust ) {
76+ this .strategyId = strategyId ;
77+ this .trust = trust ;
78+ }
79+
80+ @ Deprecated
7581 public ForkPullRequestDiscoveryTrait (int strategyId ,
7682 @ NonNull SCMHeadAuthority <? super BitbucketSCMSourceRequest , ? extends ChangeRequestSCMHead2 , ? extends SCMRevision > trust ) {
7783 this .strategyId = strategyId ;
@@ -223,11 +229,19 @@ public List<SCMHeadAuthorityDescriptor> getTrustDescriptors() {
223229 }
224230 }
225231
232+ /**
233+ * Trust policy for forked pull requests.
234+ * <p>
235+ * This reduces generics in the databound constructor method signature as a workaround for JENKINS-26535
236+ */
237+ @ SuppressWarnings ("rawtypes" )
238+ public static abstract class BitbucketForkTrustPolicy extends SCMHeadAuthority <BitbucketSCMSourceRequest , PullRequestSCMHead , PullRequestSCMRevision > {
239+ }
226240
227241 /**
228242 * An {@link SCMHeadAuthority} that trusts nothing.
229243 */
230- public static class TrustNobody extends SCMHeadAuthority < SCMSourceRequest , PullRequestSCMHead , PullRequestSCMRevision > {
244+ public static class TrustNobody extends BitbucketForkTrustPolicy {
231245
232246 /**
233247 * Constructor.
@@ -240,7 +254,7 @@ public TrustNobody() {
240254 * {@inheritDoc}
241255 */
242256 @ Override
243- public boolean checkTrusted (@ NonNull SCMSourceRequest request , @ NonNull PullRequestSCMHead head ) {
257+ public boolean checkTrusted (@ NonNull BitbucketSCMSourceRequest request , @ NonNull PullRequestSCMHead head ) {
244258 return false ;
245259 }
246260
@@ -272,8 +286,7 @@ public boolean isApplicableToOrigin(@NonNull Class<? extends SCMHeadOrigin> orig
272286 /**
273287 * An {@link SCMHeadAuthority} that trusts forks belonging to the same account.
274288 */
275- public static class TrustTeamForks
276- extends SCMHeadAuthority <BitbucketSCMSourceRequest , PullRequestSCMHead , PullRequestSCMRevision > {
289+ public static class TrustTeamForks extends BitbucketForkTrustPolicy {
277290
278291 /**
279292 * Constructor.
@@ -322,7 +335,7 @@ public boolean isApplicableToOrigin(@NonNull Class<? extends SCMHeadOrigin> orig
322335 /**
323336 * An {@link SCMHeadAuthority} that trusts everyone.
324337 */
325- public static class TrustEveryone extends SCMHeadAuthority < SCMSourceRequest , PullRequestSCMHead , PullRequestSCMRevision > {
338+ public static class TrustEveryone extends BitbucketForkTrustPolicy {
326339 /**
327340 * Constructor.
328341 */
@@ -334,7 +347,7 @@ public TrustEveryone() {
334347 * {@inheritDoc}
335348 */
336349 @ Override
337- protected boolean checkTrusted (@ NonNull SCMSourceRequest request , @ NonNull PullRequestSCMHead head ) {
350+ protected boolean checkTrusted (@ NonNull BitbucketSCMSourceRequest request , @ NonNull PullRequestSCMHead head ) {
338351 return true ;
339352 }
340353
0 commit comments