Thanks Daniel. But I didn't understand by what you meant "remove the type 
parameters". I was able to configure the trait using `configure` block. 
https://gist.github.com/baymac/f1a2249a0ec7b999c057056937e752a6 

On Saturday, August 17, 2019 at 5:09:03 PM UTC+5:30, Daniel Spilker wrote:
>
> Hi Parichay,
>
> the Job DSL script would be this:
>
> organizationFolder('example') {
>   organizations {
>     gitLabSCMNavigator {
>       projectOwner('test')
>       traits {
>         gitLabForkDiscovery {
>           strategyId(42)
>           trust {
>             gitLabTrustNobody()
>           }
>         }
>       }
>     }
>   }
> }
>
> But the script will fail. The problem is caused by the "trust" constructor 
> parameter of ForkMergeRequestDiscoveryTrait. Job DSL uses the Structs 
> plugin for introspection of Describables. Unfortunately Structs does not 
> handle parameter types with generics except for sub classes of 
> java.util.Collection. So the trait will not be shown in the API viewer.
>
> To check if a class is supported by Structs (and Job DSL), run the 
> following in the Jenkins script console:
>
> org.jenkinsci.plugins.structs.describable.DescribableModel.of(io.jenkins.plugins.gitlabbranchsource.ForkMergeRequestDiscoveryTrait)
>
> The result will be
>
> ForkMergeRequestDiscoveryTrait(strategyId: int, trust: 
> java.lang.UnsupportedOperationException: do not know how to categorize 
> attributes of type jenkins.scm.api.trait.SCMHeadAuthority<? super 
> io.jenkins.plugins.gitlabbranchsource.GitLabSCMSourceRequest, ? extends 
> jenkins.scm.api.mixin.ChangeRequestSCMHead2, ? extends 
> jenkins.scm.api.SCMRevision>)
>
> As a workaround, you can remove the type parameters from the "trust" 
> constructor parameter. 
>
> @Jesse: would it be feasible to fallback to the raw type when a 
> parameterized type is detected?
>
> https://github.com/jenkinsci/structs-plugin/blob/structs-parent-1.20/plugin/src/main/java/org/jenkinsci/plugins/structs/describable/ParameterType.java#L104
>
> Regards,
> Daniel
>
>
> On Fri, Aug 16, 2019 at 3:11 PM Parichay Barpanda <[email protected] 
> <javascript:>> wrote:
>
>> Hi all,
>>
>> I am trying to configure GitLab Branch Source Plugin organizational 
>> folder using Job DSL. But unfortunately job dsl api viewer doesn't detect 
>> Fork 
>> Merge Request Trait 
>> <https://github.com/jenkinsci/gitlab-branch-source-plugin/blob/develop/src/main/java/io/jenkins/plugins/gitlabbranchsource/ForkMergeRequestDiscoveryTrait.java>.
>>  
>> All the detected traits in Job dsl api viewer takes either 
>> int/boolean/string values. But in Fork Merge Request Trait the trust field 
>> takes an SCMHeadAuthority object. How does one configure Job DSL with fork 
>> `change request` trait for any of the branch source plugin?
>>
>> Can someone help me with figuring out what is wrong here. I have the 
>> following cases:
>>
>> 1. Job DSL doesn't support Fork Merge Request Trait.
>>
>> 2. There is something wrong with the impl of Fork Merge Request Trait.
>>
>> 3. Our Job DSL configuration is incorrect (note unable to configure fork 
>> merge request in this configuration):
>>
>> organizationFolder(name) {
>>       organizations {
>>         displayName(config.displayName)
>>         description(orgDescription)
>>         gitLabSCMNavigator {
>>           projectOwner(config.group)
>>           credentialsId('gitlab_ssh_key')
>>           serverName('git.3shape.local')
>>           traits {
>>             subGroupProjectDiscoveryTrait() // discover projects inside 
>> subgroups
>>             gitLabBranchDiscovery {
>>               strategyId(3) // discover all branches
>>             }
>>             originMergeRequestDiscoveryTrait {
>>               strategyId(1) // discover MRs and merge them with target 
>> branch
>>             }
>>             gitLabTagDiscovery() // discover tags
>>             gitLFSPullTrait()
>>           }
>>         }
>>       }
>>       orphanedItemStrategy {
>>         discardOldItems {
>>           daysToKeep(7)
>>           numToKeep(10)
>>         }
>>       }
>>       if (!isSandbox()) {
>>         triggers {
>>           periodicFolderTrigger {
>>             interval('1d')
>>           }
>>         }
>>       }
>>       projectFactories {
>>         workflowMultiBranchProjectFactory {
>>           scriptPath('Jenkinsfile')
>>         }
>>       }
>>     }
>>
>> 4. or something else?
>>
>> Thanks and Regards,
>> Parichay
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Jenkins Developers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-dev/ba6639f7-a735-4e2f-9e69-61f58762d7fa%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-dev/ba6639f7-a735-4e2f-9e69-61f58762d7fa%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/331dfda5-1c82-45bb-b508-1c3658236444%40googlegroups.com.

Reply via email to