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

Organization/Repo scan fails when MR are disabled in GitLab #285

Closed fenz closed 1 year ago

fenz commented 1 year ago

Jenkins and plugins versions report

Environment ```text GitLab version GitLab Enterprise Edition 15.7.7-ee: https://gitlab.com/gitlab-org/gitlab/-/tree/v15.7.7-ee Jenkins and plugins versions Jenkins: 2.375.3 OS: Linux - 3.10.0-1160.53.1.el7.x86_64 Java: 11.0.18 - Eclipse Adoptium (OpenJDK 64-Bit Server VM) --- ace-editor:1.1 antisamy-markup-formatter:155.v795fb_8702324 apache-httpcomponents-client-4-api:4.5.13-138.v4e7d9a_7b_a_e61 aqua-security-scanner:3.2.2 authentication-tokens:1.4 authorize-project:1.4.0 aws-credentials:191.vcb_f183ce58b_9 aws-java-sdk-ec2:1.12.406-370.v8f993c987059 aws-java-sdk-minimal:1.12.406-370.v8f993c987059 blueocean:1.27.1 blueocean-autofavorite:1.2.5 blueocean-bitbucket-pipeline:1.27.1 blueocean-commons:1.27.1 blueocean-config:1.27.1 blueocean-core-js:1.27.1 blueocean-dashboard:1.27.1 blueocean-display-url:2.4.1 blueocean-events:1.27.1 blueocean-git-pipeline:1.27.1 blueocean-github-pipeline:1.27.1 blueocean-i18n:1.27.1 blueocean-jwt:1.27.1 blueocean-personalization:1.27.1 blueocean-pipeline-api-impl:1.27.1 blueocean-pipeline-editor:1.27.1 blueocean-pipeline-scm-api:1.27.1 blueocean-rest:1.27.1 blueocean-rest-impl:1.27.1 blueocean-web:1.27.1 bootstrap4-api:4.6.0-5 bootstrap5-api:5.2.1-3 bouncycastle-api:2.27 branch-api:2.1071.v1a_188a_562481 build-token-root:151.va_e52fe3215fc build-token-trigger:1.0.0 caffeine-api:2.9.3-65.v6a_47d0f4d1fe checks-api:1.8.1 cloudbees-bitbucket-branch-source:791.vb_eea_a_476405b cloudbees-folder:6.800.v71307ca_b_986b command-launcher:90.v669d7ccb_7c31 commons-lang3-api:3.12.0-36.vd97de6465d5b_ commons-text-api:1.10.0-27.vb_fa_3896786a_7 config-file-provider:3.11.1 configuration-as-code:1569.vb_72405b_80249 credentials:1214.v1de940103927 credentials-binding:523.vd859a_4b_122e6 data-tables-api:1.12.1-4 display-url-api:2.3.7 docker-commons:1.21 docker-workflow:563.vd5d2e5c4007f durable-task:504.vb10d1ae5ba2f echarts-api:5.4.0-1 eks-token:0.0.2 email-ext:2.94 favorite:2.4.1 font-awesome-api:6.2.1-1 git:5.0.0 git-client:4.1.0 git-server:99.va_0826a_b_cdfa_d github:1.36.1 github-api:1.303-400.v35c2d8258028 github-branch-source:1701.v00cc8184df93 gitlab-api:5.0.1-78.v47a_45b_9f78b_7 gitlab-branch-source:644.va_a_66886e07b_5 gitlab-plugin:1.7.6 google-chat-notification:1.4 greenballs:1.15.1 handlebars:3.0.8 handy-uri-templates-2-api:2.1.8-22.v77d5b_75e6953 hashicorp-vault-plugin:360.v0a_1c04cf807d htmlpublisher:1.31 instance-identity:142.v04572ca_5b_265 ionicons-api:31.v4757b_6987003 jackson2-api:2.14.2-319.v37853346a_229 jakarta-activation-api:2.0.1-3 jakarta-mail-api:2.0.1-3 javax-activation-api:1.2.0-6 javax-mail-api:1.6.2-9 jaxb:2.3.8-1 jdk-tool:63.v62d2fd4b_4793 jenkins-design-language:1.27.1 jersey2-api:2.38-1 jjwt-api:0.11.5-77.v646c772fddb_0 job-dsl:1.81 jquery3-api:3.6.1-2 jsch:0.1.55.61.va_e9ee26616e7 junit:1177.v90374a_ef4d09 kubernetes:3883.v4d70a_a_a_df034 kubernetes-cli:1.12.0 kubernetes-client-api:6.4.1-208.vfe09a_9362c2c kubernetes-credentials:0.10.0 locale:226.v008e1b_58cb_b_0 lockable-resources:1123.v4002ee23c671 mailer:448.v5b_97805e3767 matrix-auth:3.1.6 matrix-project:785.v06b_7f47b_c631 metrics:4.2.13-420.vea_2f17932dd6 mina-sshd-api-common:2.9.2-50.va_0e1f42659a_a mina-sshd-api-core:2.9.2-50.va_0e1f42659a_a momentjs:1.1.1 okhttp-api:4.10.0-125.v3593b_a_f8c97b_ pipeline-build-step:2.18.1 pipeline-graph-analysis:202.va_d268e64deb_3 pipeline-groovy-lib:629.vb_5627b_ee2104 pipeline-input-step:466.v6d0a_5df34f81 pipeline-milestone-step:111.v449306f708b_7 pipeline-model-api:2.2118.v31fd5b_9944b_5 pipeline-model-definition:2.2118.v31fd5b_9944b_5 pipeline-model-extensions:2.2118.v31fd5b_9944b_5 pipeline-rest-api:2.31 pipeline-stage-step:305.ve96d0205c1c6 pipeline-stage-tags-metadata:2.2118.v31fd5b_9944b_5 pipeline-stage-view:2.31 plain-credentials:143.v1b_df8b_d3b_e48 plugin-util-api:2.20.0 popper-api:1.16.1-3 popper2-api:2.11.6-2 pubsub-light:1.17 resource-disposer:0.21 scm-api:631.v9143df5b_e4a_a script-security:1229.v4880b_b_e905a_6 simple-theme-plugin:146.v0e67db_a_9052e slack:631.v40deea_40323b snakeyaml-api:1.33-95.va_b_a_e3e47b_fa_4 sse-gateway:1.26 ssh-credentials:305.v8f4381501156 ssh-slaves:2.854.v7fd446b_337c9 sshd:3.275.v9e17c10f2571 stashNotifier:1.28 strict-crumb-issuer:2.1.0 structs:324.va_f5d6774f3a_d sysdig-secure:2.2.8 timestamper:1.22 token-macro:321.vd7cc1f2a_52c8 trilead-api:2.84.v72119de229b_7 variant:59.vf075fe829ccb workflow-aggregator:590.v6a_d052e5a_a_b_5 workflow-api:1208.v0cc7c6e0da_9e workflow-basic-steps:1010.vf7a_b_98e847c1 workflow-cps:3618.v13db_a_21f0fcf workflow-durable-task-step:1234.v019404b_3832a workflow-job:1268.v6eb_e2ee1a_85a workflow-multibranch:733.v109046189126 workflow-scm-step:400.v6b_89a_1317c9a_ workflow-step-api:639.v6eca_cd8c04a_a_ workflow-support:839.v35e2736cfd5c ws-cleanup:0.44 ```

What Operating System are you using (both controller, and any agents involved in the problem)?

OS: Linux (running as k8s pod)

Reproduction steps

  1. Disable MRs in the repo visualisation MR_disable

  2. Scan GitLab repo from Jenkins GitLab_Plugin_error

Expected Results

Skip discovering MRs for repos where they are disabled. If not possible, at least skip the scan for the specific repo and continue with scanning other repos in the same organization.

Actual Results

If a repo has the MRs disabled, the Jenkins scan for the whole Organization fails and other repos are not discovered at all. Based on the alphabetic order, if the error happens on the first repo in an Organization (Group/Subgroup/User) none of the repos will be scanned (even if the MRs is disabled only for the first repo).

Anything else?

I tried to change discover behaviour for the MR in Jenkins plugin but nothing worked. I even gave "maintainer" role to the Jenkins user used for scanning the repos but it didn't help.

jmini commented 1 year ago

Do you have the "Discover merge requests from origin" behavior (and maybe "Discover merge requests from forks") set or not in the Jenkins project configuration?

Jenkins configuration

If yes I would check if removing them has any impact.

fenz commented 1 year ago

Hi! I do have it set (same way you have) and tried to change it to different values, no change in the behaviour.

fenz commented 1 year ago

I tried now also to remove and no change still. My repository has also no MRs at all. I see in the configuration the "Discover branches". Screenshot 2023-03-29 at 17 53 13

The MRs discovery seems to be involved here as well. That's probably why the other configuration is not really affecting the behaviour. I think the plugin fails already during the branch discovery (because of the MR view limitation).

Turiok commented 1 year ago

@fenz please check the pull request.

It works in my home installation but it'll be better if you check too. Please check other configurations too.

fenz commented 1 year ago

@Turiok We just finished testing your fix. Things seems to work fine. What would be needed to promote this fix to be added to the next release?

Turiok commented 1 year ago

@fenz The maintainer will look at the RP. If he has no comments, he will make a version.

fenz commented 1 year ago

@Turiok any idea if this will ever be merged? Is there any issue with the PR?

fenz commented 1 year ago

@jetersen apologies for bothering you but was wondering if there's any reason for this fix to not being merged and hanging here for many months. Is there anything we can do to move this on?

jetersen commented 1 year ago

@fenz should be released in https://github.com/jenkinsci/gitlab-branch-source-plugin/releases/tag/670.vf7df45517001

fenz commented 1 year ago

@jetersen many thanks!