[JIRA] (JENKINS-60874) Cannot configure ForkPullRequestDiscoveryTrait by using Job DSL dynamic API

28 views
Skip to first unread message

adam.gabrys@live.com (JIRA)

unread,
Jan 27, 2020, 7:56:04 AM1/27/20
to jenkinsc...@googlegroups.com
Adam Gabryś created an issue
 
Jenkins / Task JENKINS-60874
Cannot configure ForkPullRequestDiscoveryTrait by using Job DSL dynamic API
Issue Type: Task Task
Assignee: Daniel Spilker
Components: github-branch-source-plugin, job-dsl-plugin
Created: 2020-01-27 12:55
Priority: Major Major
Reporter: Adam Gabryś

GitHub Branch Source plugin has introduced unique symbols (not released yet), so finally we are able to configure traits by using Job DSL dynamic API instead of configure block. Unfortunately, ForkPullRequestDiscoveryTrait (gitHubForkDiscovery) is unavailable. For now the only possible option is to still use configure block:

branchSources {
    branchSource {
        source {
            github {
                apiUri(config.scm.apiUrl)
                id(config.name)
                repoOwner(config.scm.organisation)
                repository(config.scm.repository)
                repositoryUrl(config.scm.url)
                configuredByUrl(false)
                credentialsId(config.scm.credentialsId)
                traits {
                    gitHubBranchDiscovery {
                        strategyId(3)
                    }
                    gitHubPullRequestDiscovery {
                        strategyId(1)
                    }
                }
            }
        }
        buildStrategies {
            skipInitialBuildOnFirstBranchIndexing()
        }
    }
}
configure {
    def traits = it / 'sources' / 'data' / 'jenkins.branch.BranchSource' / 'source' / 'traits'
    traits << 'org.jenkinsci.plugins.github__branch__source.ForkPullRequestDiscoveryTrait' {
        strategyId(1)
        trust(class: 'org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait$TrustPermission')
    }
}
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

adam.gabrys@live.com (JIRA)

unread,
Jan 27, 2020, 7:56:06 AM1/27/20
to jenkinsc...@googlegroups.com

adam.gabrys@live.com (JIRA)

unread,
Jan 27, 2020, 7:58:05 AM1/27/20
to jenkinsc...@googlegroups.com
Adam Gabryś updated an issue
Change By: Adam Gabryś
Environment: Job DSL: 1.76
GitHub Branch Source: 2.5.9-SNAPSHOT (commit: 7179854f068f0012b3d1222f6924e8de5d437513)

adam.gabrys@live.com (JIRA)

unread,
Jan 27, 2020, 8:12:04 AM1/27/20
to jenkinsc...@googlegroups.com
Adam Gabryś updated an issue
GitHub Branch Source plugin has introduced unique symbols (not released yet), so finally we are able to configure traits by using Job DSL dynamic API instead of {{configure block}}. Unfortunately, ForkPullRequestDiscoveryTrait ({{gitHubForkDiscovery}}) is unavailable. For now the only possible option is to still use {{configure}} block:
{code}

branchSources {
    branchSource {
        source {
            github {
                apiUri(config.scm.apiUrl)
                id(config.name)
                repoOwner(config.scm.organisation)
                repository(config.scm.repository)
                repositoryUrl(config.scm.url)
                configuredByUrl(false)
                credentialsId(config.scm.credentialsId)
                traits {
                    gitHubBranchDiscovery {
                     strategyId(3)
                    }
                    gitHubPullRequestDiscovery {
                     strategyId(1)
                    }
                }
            }
        }
        buildStrategies {
            skipInitialBuildOnFirstBranchIndexing()
        }
    }
}
configure {
    def traits = it / 'sources' / 'data' / 'jenkins.branch.BranchSource' / 'source' / 'traits'
    traits << 'org.jenkinsci.plugins.github__branch__source.ForkPullRequestDiscoveryTrait' {
        strategyId(1)
        trust(class: 'org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait$TrustPermission')
    }
}
{code}

List of available traits:
* gitHubAgedRefsTrait
* gitHubBranchDiscovery
* gitHubSshCheckout
* gitHubTagDiscovery

Missing:
* gitHubForkDiscovery
* gitHubPullRequestDiscovery

adam.gabrys@live.com (JIRA)

unread,
Jan 27, 2020, 8:22:04 AM1/27/20
to jenkinsc...@googlegroups.com
Adam Gabryś updated an issue
Change By: Adam Gabryś
Summary: Cannot configure ForkPullRequestDiscoveryTrait and OriginPullRequestDiscoveryTrait by using Job DSL dynamic API

adam.gabrys@live.com (JIRA)

unread,
Jan 27, 2020, 8:23:02 AM1/27/20
to jenkinsc...@googlegroups.com

adam.gabrys@live.com (JIRA)

unread,
Jan 27, 2020, 9:12:06 AM1/27/20
to jenkinsc...@googlegroups.com
List of available traits in Job DSL Dynamic API Vievwer :

* gitHubAgedRefsTrait
* gitHubBranchDiscovery
* gitHubSshCheckout
* gitHubTagDiscovery

Missing:
* gitHubPullRequestDiscovery ← I'm able to configure
*
gitHubForkDiscovery ← I'm not able to configure

I tried:
{code}
gitHubForkDiscovery {
    strategyId(1)
    trust('trustPermission')
}
{code}

adam.gabrys@live.com (JIRA)

unread,
Jan 27, 2020, 9:36:03 AM1/27/20
to jenkinsc...@googlegroups.com
Adam Gabryś updated an issue
GitHub Branch Source plugin has introduced unique symbols (not released yet), so finally we are able to configure traits by using Job DSL dynamic API instead of {{configure block}}. Unfortunately, ForkPullRequestDiscoveryTrait ({{gitHubForkDiscovery}}) is unavailable. For now the only possible option is to still use {{configure}} block:
{code :java }
* gitHubPullRequestDiscovery
*
gitHubSshCheckout
* gitHubTagDiscovery

Missing:
*
gitHubPullRequestDiscovery ← I'm able to configure
*
gitHubForkDiscovery ← I'm not able to configure missing, but exists

I tried:
1)
{code :java }

gitHubForkDiscovery {
    strategyId(1)
    trust('trustPermission')
}
{code}

{noformat}
ERROR: (unknown source) No signature of method: javaposse.jobdsl.plugin.structs.DescribableContext.trust() is applicable for argument types: (java.lang.String) values: [trustPermission]
Possible solutions: getAt(java.lang.String), print(java.io.PrintWriter), use([Ljava.lang.Object;), print(java.lang.Object), wait(), dump()
{noformat}
2)
{code:java}
gitHubForkDiscovery {
    strategyId(1)
    trust(gitHubTrustPermissions)
}
{code}
{noformat}
ERROR: (MultibranchJobFactory.groovy, line 89) No such property: gitHubTrustPermissions for class: javaposse.jobdsl.plugin.structs.DescribableContext
{noformat}
3)
{code:java}
gitHubForkDiscovery {
    strategyId(1)
    trust(gitHubTrustPermissions())
}
{code}
{noformat}
ERROR: (unknown source) No signature of method: javaposse.jobdsl.plugin.structs.DescribableContext.gitHubTrustPermissions() is applicable for argument types: () values: []
{noformat}
4)
{code:java}
gitHubForkDiscovery {
    strategyId(1)
    trust {
        gitHubTrustPermissions()
    }
}
{code}
{noformat}
ERROR: (unknown source) No signature of method: javaposse.jobdsl.plugin.structs.DescribableContext.gitHubTrustPermissions() is applicable for argument types: () values: []
{noformat}
5)
{code:java}
gitHubForkDiscovery {
    strategyId(1)
        gitHubForkDiscovery {
         strategyId(1)
         trust(Class.forName('org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait$TrustPermission', true, Jenkins.get().pluginManager.uberClassLoader).getDeclaredConstructor().newInstance())
        }
}
{code}
{noformat}
ERROR: (unknown source) No signature of method: javaposse.jobdsl.plugin.structs.DescribableContext.gitHubTrustPermissions() is applicable for argument types: () values: []
{noformat}
5)

adam.gabrys@live.com (JIRA)

unread,
Jan 27, 2020, 9:40:03 AM1/27/20
to jenkinsc...@googlegroups.com
* gitHubForkDiscovery ← missing, but exists possible to execute

{code}
{noformat}
ERROR: (unknown source) No signature of method: javaposse.jobdsl.plugin.structs.DescribableContext.
gitHubTrustPermissions trust () is applicable for argument types: ( org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait$TrustPermission ) values: [ org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait$TrustPermission@3a41ed6e ]
Possible solutions: print(java.io.PrintWriter), use([Ljava.lang.Object;), print(java.lang.Object), wait(), dump(), grep()
{noformat}
5)

robin.smith@forgerock.com (JIRA)

unread,
Feb 18, 2020, 4:29:02 AM2/18/20
to jenkinsc...@googlegroups.com
Robin Smith commented on Bug JENKINS-60874
 
Re: Cannot configure ForkPullRequestDiscoveryTrait by using Job DSL dynamic API

Similar issue reported for the Bitbucket Branch source plugin: JENKINS-61119

Reply all
Reply to author
Forward
0 new messages