Unable to configure Fork Change Request Trait using Job DSL

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Unable to configure Fork Change Request Trait using Job DSL

Parichay Barpanda
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. 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/ba6639f7-a735-4e2f-9e69-61f58762d7fa%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to configure Fork Change Request Trait using Job DSL

Jesse Glick-4
On Fri, Aug 16, 2019 at 9:11 AM Parichay Barpanda
<[hidden email]> wrote:
> 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?

I presume like any other `Describable`: you need to pick an
implementation with a `@Symbol`, like

https://github.com/jenkinsci/gitlab-branch-source-plugin/blob/c0c8236ff87b9bc48110690de8eba99a10966e81/src/main/java/io/jenkins/plugins/gitlabbranchsource/ForkMergeRequestDiscoveryTrait.java#L230

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr1UjomXq8GKBa0GDsHcCPVMswTGUO64csqDCfC0mVadYw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to configure Fork Change Request Trait using Job DSL

Parichay Barpanda
Can you tell how to do it? We are unable to find the configuration in the api viewer.

Thanks.

On Fri 16 Aug, 2019, 20:07 Jesse Glick, <[hidden email]> wrote:
On Fri, Aug 16, 2019 at 9:11 AM Parichay Barpanda
<[hidden email]> wrote:
> 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?

I presume like any other `Describable`: you need to pick an
implementation with a `@Symbol`, like

https://github.com/jenkinsci/gitlab-branch-source-plugin/blob/c0c8236ff87b9bc48110690de8eba99a10966e81/src/main/java/io/jenkins/plugins/gitlabbranchsource/ForkMergeRequestDiscoveryTrait.java#L230

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr1UjomXq8GKBa0GDsHcCPVMswTGUO64csqDCfC0mVadYw%40mail.gmail.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWAOYbhfBBFWqVt9YOFgojr2u8UapSOX2XBpK%3DzRbQaVaig%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to configure Fork Change Request Trait using Job DSL

Jesse Glick-4
On Fri, Aug 16, 2019 at 11:03 AM Parichay Barpanda
<[hidden email]> wrote:
> Can you tell how to do it? We are unable to find the configuration in the api viewer.

Sounds like a question for the users’ list which perhaps the `job-dsl`
maintainer(s) could answer.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr076buFXWuRuHSLdrRQ3vcRfgiBCRSNtUiAt8GGJQrFXw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to configure Fork Change Request Trait using Job DSL

Daniel Spilker
In reply to this post by Parichay Barpanda
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?

Regards,
Daniel


On Fri, Aug 16, 2019 at 3:11 PM Parichay Barpanda <[hidden email]> 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. 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/ba6639f7-a735-4e2f-9e69-61f58762d7fa%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAKqW32BGcjAZFF4fQA%3DDjM%2B9N%2Bf7VCn6pZ6%2Bh%3Di0TH3-za-DTA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to configure Fork Change Request Trait using Job DSL

Jesse Glick-4
On Sat, Aug 17, 2019 at 7:39 AM Daniel Spilker <[hidden email]> wrote:
> @Jesse: would it be feasible to fallback to the raw type when a parameterized type is detected?

Best to discuss in JENKINS-26535 which I am guessing describes the
same problem. Probably not a very difficult bug to fix—easily explored
via unit tests.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2AccVGi24BNTazhOtrBsatrYT3Vj1dMsJAUK-JFzH29w%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to configure Fork Change Request Trait using Job DSL

Parichay Barpanda
In reply to this post by Daniel Spilker
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?
<a href="https://github.com/jenkinsci/structs-plugin/blob/structs-parent-1.20/plugin/src/main/java/org/jenkinsci/plugins/structs/describable/ParameterType.java#L104" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fstructs-plugin%2Fblob%2Fstructs-parent-1.20%2Fplugin%2Fsrc%2Fmain%2Fjava%2Forg%2Fjenkinsci%2Fplugins%2Fstructs%2Fdescribable%2FParameterType.java%23L104\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFST7m5-3jjLlVRd4aEUTX_0T3gg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fstructs-plugin%2Fblob%2Fstructs-parent-1.20%2Fplugin%2Fsrc%2Fmain%2Fjava%2Forg%2Fjenkinsci%2Fplugins%2Fstructs%2Fdescribable%2FParameterType.java%23L104\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFST7m5-3jjLlVRd4aEUTX_0T3gg&#39;;return true;">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 <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="yj5Xrn5vFQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">parichay...@...> 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 <a href="https://github.com/jenkinsci/gitlab-branch-source-plugin/blob/develop/src/main/java/io/jenkins/plugins/gitlabbranchsource/ForkMergeRequestDiscoveryTrait.java" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fgitlab-branch-source-plugin%2Fblob%2Fdevelop%2Fsrc%2Fmain%2Fjava%2Fio%2Fjenkins%2Fplugins%2Fgitlabbranchsource%2FForkMergeRequestDiscoveryTrait.java\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEsTEPt-64oIWfAiXctgLSJVlfNiQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fgitlab-branch-source-plugin%2Fblob%2Fdevelop%2Fsrc%2Fmain%2Fjava%2Fio%2Fjenkins%2Fplugins%2Fgitlabbranchsource%2FForkMergeRequestDiscoveryTrait.java\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEsTEPt-64oIWfAiXctgLSJVlfNiQ&#39;;return true;">Fork Merge Request Trait. 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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="yj5Xrn5vFQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkin...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/ba6639f7-a735-4e2f-9e69-61f58762d7fa%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/ba6639f7-a735-4e2f-9e69-61f58762d7fa%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/ba6639f7-a735-4e2f-9e69-61f58762d7fa%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/ba6639f7-a735-4e2f-9e69-61f58762d7fa%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/331dfda5-1c82-45bb-b508-1c3658236444%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to configure Fork Change Request Trait using Job DSL

Daniel Spilker
Hi Parichay,

I meant changing the constructor to

public ForkMergeRequestDiscoveryTrait(int strategyId, SCMHeadAuthority trust) {

until Structs plugin supports parameters with parameterized type.

I opened a pull request to add some support for parameterized types to Structs plugin:

I tested the fix with Job DSL. It will enable the DSL syntax from my previous post.

Regards,
Daniel


On Mon, Aug 19, 2019 at 5:39 PM Parichay Barpanda <[hidden email]> wrote:
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?

Regards,
Daniel


On Fri, Aug 16, 2019 at 3:11 PM Parichay Barpanda <[hidden email]> 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. 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/ba6639f7-a735-4e2f-9e69-61f58762d7fa%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/331dfda5-1c82-45bb-b508-1c3658236444%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAKqW32CqQimaZ4v%2BkQ1sMuWWuUeyGU9jzb-5Q4sVUnMevpwRBw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to configure Fork Change Request Trait using Job DSL

Parichay Barpanda
Thanks for clarifying it. Also nice to know a fix is at work. 

On Tue 20 Aug, 2019, 00:47 Daniel Spilker, <[hidden email]> wrote:
Hi Parichay,

I meant changing the constructor to

public ForkMergeRequestDiscoveryTrait(int strategyId, SCMHeadAuthority trust) {

until Structs plugin supports parameters with parameterized type.

I opened a pull request to add some support for parameterized types to Structs plugin:

I tested the fix with Job DSL. It will enable the DSL syntax from my previous post.

Regards,
Daniel


On Mon, Aug 19, 2019 at 5:39 PM Parichay Barpanda <[hidden email]> wrote:
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?

Regards,
Daniel


On Fri, Aug 16, 2019 at 3:11 PM Parichay Barpanda <[hidden email]> 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. 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/ba6639f7-a735-4e2f-9e69-61f58762d7fa%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/331dfda5-1c82-45bb-b508-1c3658236444%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAKqW32CqQimaZ4v%2BkQ1sMuWWuUeyGU9jzb-5Q4sVUnMevpwRBw%40mail.gmail.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAD0DWANO9ZCE%2BmNrVaD%3DvLZRbFSvXymgP0x-%2BQk6gNvDyuq0bA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to configure Fork Change Request Trait using Job DSL

Joseph P
In reply to this post by Daniel Spilker
Thanks for creating a patch for this 🥰

/Joseph

On Monday, August 19, 2019 at 9:17:45 PM UTC+2, Daniel Spilker wrote:
Hi Parichay,

I meant changing the constructor to

public ForkMergeRequestDiscoveryTrait(int strategyId, SCMHeadAuthority trust) {

until Structs plugin supports parameters with parameterized type.

I opened a pull request to add some support for parameterized types to Structs plugin:
<a href="https://github.com/jenkinsci/structs-plugin/pull/52" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fstructs-plugin%2Fpull%2F52\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEEYZIsTC1I1KkHoPnEKyV2vW3uWw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fstructs-plugin%2Fpull%2F52\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEEYZIsTC1I1KkHoPnEKyV2vW3uWw&#39;;return true;">https://github.com/jenkinsci/structs-plugin/pull/52

I tested the fix with Job DSL. It will enable the DSL syntax from my previous post.

Regards,
Daniel


On Mon, Aug 19, 2019 at 5:39 PM Parichay Barpanda <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="371VoaxyAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">parichay...@...> wrote:
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. <a href="https://gist.github.com/baymac/f1a2249a0ec7b999c057056937e752a6" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgist.github.com%2Fbaymac%2Ff1a2249a0ec7b999c057056937e752a6\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHB8qu763j1OSO4hwFl6KBKOTCZfA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgist.github.com%2Fbaymac%2Ff1a2249a0ec7b999c057056937e752a6\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHB8qu763j1OSO4hwFl6KBKOTCZfA&#39;;return true;">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?
<a href="https://github.com/jenkinsci/structs-plugin/blob/structs-parent-1.20/plugin/src/main/java/org/jenkinsci/plugins/structs/describable/ParameterType.java#L104" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fstructs-plugin%2Fblob%2Fstructs-parent-1.20%2Fplugin%2Fsrc%2Fmain%2Fjava%2Forg%2Fjenkinsci%2Fplugins%2Fstructs%2Fdescribable%2FParameterType.java%23L104\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFST7m5-3jjLlVRd4aEUTX_0T3gg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fstructs-plugin%2Fblob%2Fstructs-parent-1.20%2Fplugin%2Fsrc%2Fmain%2Fjava%2Forg%2Fjenkinsci%2Fplugins%2Fstructs%2Fdescribable%2FParameterType.java%23L104\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFST7m5-3jjLlVRd4aEUTX_0T3gg&#39;;return true;">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 <[hidden email]> 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 <a href="https://github.com/jenkinsci/gitlab-branch-source-plugin/blob/develop/src/main/java/io/jenkins/plugins/gitlabbranchsource/ForkMergeRequestDiscoveryTrait.java" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fgitlab-branch-source-plugin%2Fblob%2Fdevelop%2Fsrc%2Fmain%2Fjava%2Fio%2Fjenkins%2Fplugins%2Fgitlabbranchsource%2FForkMergeRequestDiscoveryTrait.java\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEsTEPt-64oIWfAiXctgLSJVlfNiQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fgitlab-branch-source-plugin%2Fblob%2Fdevelop%2Fsrc%2Fmain%2Fjava%2Fio%2Fjenkins%2Fplugins%2Fgitlabbranchsource%2FForkMergeRequestDiscoveryTrait.java\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEsTEPt-64oIWfAiXctgLSJVlfNiQ&#39;;return true;">Fork Merge Request Trait. 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 [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/ba6639f7-a735-4e2f-9e69-61f58762d7fa%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/ba6639f7-a735-4e2f-9e69-61f58762d7fa%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/ba6639f7-a735-4e2f-9e69-61f58762d7fa%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/ba6639f7-a735-4e2f-9e69-61f58762d7fa%40googlegroups.com.

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="371VoaxyAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkin...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/331dfda5-1c82-45bb-b508-1c3658236444%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/331dfda5-1c82-45bb-b508-1c3658236444%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/331dfda5-1c82-45bb-b508-1c3658236444%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/331dfda5-1c82-45bb-b508-1c3658236444%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/ca4ce035-38e9-43d6-b53e-734c9e92aeca%40googlegroups.com.