jenkinsci / gitlab-branch-source-plugin

A Jenkins Plugin for GitLab Multibranch Pipeline jobs and Folder Organization
https://plugins.jenkins.io/gitlab-branch-source
MIT License
122 stars 87 forks source link

Cannot configure ForkMergeRequestDiscoveryTrait with job-dsl #130

Open herbert-venancio opened 3 years ago

herbert-venancio commented 3 years ago

Version report

Jenkins and plugins versions report:

Jenkins: 2.284
OS: Linux - 4.15.0-137-generic
---
durable-task:1.35
custom-tools-plugin:0.8
gitlab-api:1.0.6
plain-credentials:1.7
git-client:3.7.0
pam-auth:1.6
git-server:1.9
momentjs:1.1.1
ssh-credentials:1.18.2
email-ext:2.82
script-security:1.76
apache-httpcomponents-client-4-api:4.5.13-1.0
checks-api:1.6.1
mailer:1.33
display-url-api:2.3.4
h2-api:1.4.199
antisamy-markup-formatter:2.1
timestamper:1.12
pipeline-model-extensions:1.8.4
jjwt-api:0.11.2-9.c8b45b8bb173
jquery3-api:3.5.1-3
ldap:2.4
jackson2-api:2.12.1
pipeline-milestone-step:1.3.2
pipeline-stage-view:2.19
workflow-cps:2.90
theme-manager:0.6
cloudbees-folder:6.15
popper-api:1.16.1-2
job-dsl:1.77
workflow-scm-step:2.12
github-api:1.123
workflow-job:2.40
pipeline-model-api:1.8.4
lockable-resources:2.10
plugin-util-api:2.0.0
workflow-api:2.42
handy-uri-templates-2-api:2.1.8-1.0
bootstrap4-api:4.6.0-2
workflow-basic-steps:2.23
jdk-tool:1.5
ws-cleanup:0.39
junit:1.49
workflow-cps-global-lib:2.18
pipeline-model-definition:1.8.4
github-branch-source:2.10.2
snakeyaml-api:1.27.0
structs:1.22
bouncycastle-api:2.20
credentials-binding:1.24
pipeline-build-step:2.13
github:1.33.1
handlebars:1.1.1
config-file-provider:3.7.0
pipeline-maven:3.10.0
gitlab-branch-source:1.5.4
credentials:2.3.15
gradle:1.36
jsch:0.1.55.2
workflow-aggregator:2.6
trilead-api:1.0.13
workflow-support:3.8
scm-api:2.6.4
matrix-auth:2.6.6
font-awesome-api:5.15.2-2
git:4.7.0
ace-editor:1.1
token-macro:2.15
echarts-api:5.0.1-1
command-launcher:1.5
workflow-step-api:2.23
workflow-multibranch:2.22
branch-api:2.6.3
build-timeout:1.20
workflow-durable-task-step:2.38
pipeline-stage-tags-metadata:1.8.4
pipeline-graph-analysis:1.10
okhttp-api:3.14.9
matrix-project:1.18
pipeline-input-step:2.12
pipeline-rest-api:2.19
pipeline-github-lib:1.0
pipeline-stage-step:2.5
jquery:1.12.4-1
sshd:3.0.3
ssh-slaves:1.31.6
dark-theme:0.0.12
ant:1.11
resource-disposer:0.15
extended-choice-parameter:0.82

Reproduction steps

Results

Expected result:

Discover merge requests from forks available in traits

Actual result:

No fork trait in the list of traits

Notes:

I can almost add it by guessing, but the trust property is a mystery:

multibranchPipelineJob(JOB_NAME) {
    branchSources {
        branchSource {
            source {
                gitlab {
                    serverName('server-name')
                    projectOwner('project-owner')
                    projectPath('project-owner/project')
                    credentialsId('credentials-id')
                    traits {
                        forkMergeRequestDiscoveryTrait {
                            strategyId(1)
                            trust(????)
                        }
                    }
                }
            }
        }
    }
}
herbert-venancio commented 3 years ago

Similar issue with github-branch-source-plugin: https://issues.jenkins.io/browse/JENKINS-60874

TobiX commented 3 years ago

Workaround:

      branchSources {
        branchSource {
          source {
            gitLabSCMSource {
              // NORMAL CONFIG HERE
            }
          }
        }
      }

      configure {
        it / sources / data / 'jenkins.branch.BranchSource' / source / traits / 'io.jenkins.plugins.gitlabbranchsource.ForkMergeRequestDiscoveryTrait' {
          strategyId 1
          trust(class: 'io.jenkins.plugins.gitlabbranchsource.ForkMergeRequestDiscoveryTrait$TrustPermission')
        }
      }