What Operating System are you using (both controller, and any agents involved in the problem)?
This is on containerized Jenkins 2.462.2, using the latest available plugin version (710.v6f19df32544b_).
Reproduction steps
Create an Organization Folder that pulls in from a group containing 2 projects from GitLab: one project is a standalone project, another project is forked from that.
Enable "Discover merge requests from forks", with the Strategy "Merging the merge request with the current target branch version", and Trust set to "Trusted Members", and enable "Build MRs of forks that are not mirrors"
Trigger a Scan of the GitLab Group
Expected Results
All projects scanned successfully, with no NPE.
Actual Results
The scanner fails due to an NPE on the base project, but the forked project succeeds:
java.lang.NullPointerException: Cannot invoke "org.gitlab4j.api.models.Project.getId()" because the return value of "org.gitlab4j.api.models.Project.getForkedFromProject()" is null
at PluginClassLoader for gitlab-branch-source//io.jenkins.plugins.gitlabbranchsource.GitLabSCMSource.lambda$retrieve$1(GitLabSCMSource.java:355)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
at PluginClassLoader for gitlab-branch-source//io.jenkins.plugins.gitlabbranchsource.GitLabSCMSource.retrieve(GitLabSCMSource.java:362)
at PluginClassLoader for scm-api//jenkins.scm.api.SCMSource._retrieve(SCMSource.java:372)
at PluginClassLoader for scm-api//jenkins.scm.api.SCMSource.fetch(SCMSource.java:326)
at PluginClassLoader for branch-api//jenkins.branch.MultiBranchProjectFactory$BySCMSourceCriteria.recognizes(MultiBranchProjectFactory.java:262)
at PluginClassLoader for branch-api//jenkins.branch.OrganizationFolder$SCMSourceObserverImpl$1.recognizes(OrganizationFolder.java:1356)
at PluginClassLoader for branch-api//jenkins.branch.OrganizationFolder$SCMSourceObserverImpl$1.complete(OrganizationFolder.java:1371)
at PluginClassLoader for scm-api//jenkins.scm.api.trait.SCMNavigatorRequest.process(SCMNavigatorRequest.java:252)
at PluginClassLoader for scm-api//jenkins.scm.api.trait.SCMNavigatorRequest.process(SCMNavigatorRequest.java:202)
at PluginClassLoader for gitlab-branch-source//io.jenkins.plugins.gitlabbranchsource.GitLabSCMNavigator.visitSources(GitLabSCMNavigator.java:309)
at PluginClassLoader for branch-api//jenkins.branch.OrganizationFolder.computeChildren(OrganizationFolder.java:530)
at PluginClassLoader for cloudbees-folder//com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:269)
at PluginClassLoader for cloudbees-folder//com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:167)
at PluginClassLoader for branch-api//jenkins.branch.OrganizationFolder$OrganizationScan.run(OrganizationFolder.java:915)
at hudson.model.ResourceController.execute(ResourceController.java:101)
at hudson.model.Executor.run(Executor.java:446)
The above would be correct because we (potentially) want to include MRs for non-forked projects, so if there's no fork, then this specific condition should not be evaluated.
Jenkins and plugins versions report
Environment
```text Jenkins: 2.462.2 OS: Linux - 5.14.21-150500.55.68-default Java: 17.0.12 - Eclipse Adoptium (OpenJDK 64-Bit Server VM) --- active-directory:2.36 ansible:403.v8d0ca_dcb_b_502 ansible-tower:0.16.0 ansicolor:1.0.4 ant:511.v0a_a_1a_334f41b_ antisamy-markup-formatter:162.v0e6ec0fcfcf6 apache-httpcomponents-client-4-api:4.5.14-208.v438351942757 apache-httpcomponents-client-5-api:5.4-118.v199115451c4d asm-api:9.7-33.v4d23ef79fcc8 authentication-tokens:1.119.v50285141b_7e1 aws-credentials:231.v08a_59f17d742 aws-global-configuration:130.v35b_7b_96f53c3 aws-java-sdk:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-api-gateway:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-autoscaling:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-cloudformation:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-cloudfront:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-codebuild:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-codedeploy:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-ec2:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-ecr:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-ecs:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-efs:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-elasticbeanstalk:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-elasticloadbalancingv2:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-iam:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-kinesis:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-lambda:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-logs:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-minimal:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-organizations:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-secretsmanager:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-sns:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-sqs:1.12.767-467.vb_e93f0c614b_6 aws-java-sdk-ssm:1.12.767-467.vb_e93f0c614b_6 azure-ad:507.vea_a_a_167b_d05c azure-sdk:174.va_89c1df897d2 bootstrap5-api:5.3.3-1 bouncycastle-api:2.30.1.78.1-248.ve27176eb_46cb_ branch-api:2.1178.v969d9eb_c728e build-everything-strategy:1.0-SNAPSHOT (private-2e232de0-diego) build-timeout:1.33 caffeine-api:3.1.8-133.v17b_1ff2e0599 checks-api:2.2.1 cloud-stats:336.v788e4055508b_ cloudbees-bitbucket-branch-source:888.v8e6d479a_1730 cloudbees-folder:6.955.v81e2a_35c08d3 command-launcher:115.vd8b_301cc15d0 commons-compress-api:1.26.1-2 commons-lang3-api:3.17.0-84.vb_b_938040b_078 commons-text-api:1.12.0-129.v99a_50df237f7 config-file-provider:978.v8e85886ffdc4 configuration-as-code:1850.va_a_8c31d3158b_ configuration-as-code-groovy:1.1 coordinator:1.5.0 copyartifact:749.vfb_dca_a_9b_6549 coverage:1.16.1 credentials:1378.v81ef4269d764 credentials-binding:681.vf91669a_32e45 custom-folder-icon:2.14 data-tables-api:2.1.6-1 depbuilder:1.1.0 display-url-api:2.204.vf6fddd8a_8b_e9 docker-commons:443.v921729d5611d docker-java-api:3.4.0-94.v65ced49b_a_7d5 docker-plugin:1.6.2 docker-workflow:580.vc0c340686b_54 durable-task:577.v2a_8a_4b_7c0247 echarts-api:5.5.1-1 eddsa-api:0.3.0-4.v84c6f0f4969e email-ext:1844.v3ea_a_b_842374a_ envinject:2.919.v009a_a_1067cd0 envinject-api:1.199.v3ce31253ed13 extensible-choice-parameter:1.8.1 favorite:2.221.v19ca_666b_62f5 file-operations:266.v9d4e1eb_235b_a_ file-parameters:339.v4b_cc83e11455 folder-properties:1.2.1 font-awesome-api:6.6.0-2 forensics-api:2.6.0 generic-webhook-trigger:2.2.2 git:5.5.1 git-client:5.0.0 git-server:126.v0d945d8d2b_39 github:1.40.0 github-api:1.321-468.v6a_9f5f2d5a_7e github-branch-source:1797.v86fdb_4d57d43 github-checks:589.v845136f916cd github-pullrequest:0.7.0 gitlab-api:5.6.0-97.v6603a_83f8690 gitlab-branch-source:710.v6f19df32544b_ gitlab-plugin:1.8.1 gradle:2.13 gson-api:2.11.0-41.v019fcf6125dc h2-api:11.1.4.199-30.v1c64e772f3a_c handy-uri-templates-2-api:2.1.8-30.v7e777411b_148 hidden-parameter:237.v4b_df26c7a_f0e htmlpublisher:1.36 instance-identity:185.v303dc7c645f9 ionicons-api:74.v93d5eb_813d5f jackson2-api:2.17.0-379.v02de8ec9f64c jacoco:3.3.6 jakarta-activation-api:2.1.3-1 jakarta-mail-api:2.1.3-1 javadoc:280.v050b_5c849f69 javax-activation-api:1.2.0-7 javax-mail-api:1.6.2-10 jaxb:2.3.9-1 jdk-tool:80.v8a_dee33ed6f0 jersey2-api:2.44-151.v6df377fff741 jjwt-api:0.11.5-112.ve82dfb_224b_a_d job-fan-in:1.1.4 jobcacher:551.ve0b_00cb_1b_85c joda-time-api:2.13.0-85.vb_64d1c2921f1 jquery3-api:3.7.1-2 jsch:0.2.16-86.v42e010d9484b_ json-api:20240303-41.v94e11e6de726 json-path-api:2.9.0-58.v62e3e85b_a_655 junit:1302.va_b_878c32eb_b_5 kubernetes:4290.v93ea_4b_b_26a_61 kubernetes-client-api:6.10.0-240.v57880ce8b_0b_2 kubernetes-credentials:190.v03c305394deb_ ldap:725.v3cb_b_711b_1a_ef mailer:472.vf7c289a_4b_420 matrix-auth:3.2.2 matrix-project:832.va_66e270d2946 maven-artifact-choicelistprovider:1.18-SNAPSHOT (private-b89dc7d6-diego) metrics:4.2.21-451.vd51df8df52ec mina-sshd-api-common:2.13.2-125.v200281b_61d59 mina-sshd-api-core:2.13.2-125.v200281b_61d59 minio:1.3.3-rc93.9e92f846d4cf multibranch-action-triggers:1.8.10 multibranch-build-strategy-extension:51.v88f14e2a_4075 multibranch-job-tear-down:1.2 nodejs:1.6.2 okhttp-api:4.11.0-172.vda_da_1feeb_c6e oss-symbols-api:75.v337a_1c270ffc pam-auth:1.11 parameterized-scheduler:277.v61a_4b_a_49a_c5c pipeline-aws:1.45 pipeline-build-step:540.vb_e8849e1a_b_d8 pipeline-config-history:1.6 pipeline-github-lib:61.v629f2cc41d83 pipeline-graph-analysis:216.vfd8b_ece330ca_ pipeline-graph-view:340.v28cecee8b_25f pipeline-groovy-lib:730.ve57b_34648c63 pipeline-input-step:495.ve9c153f6067b_ pipeline-maven:1421.v610fa_b_e2d60e pipeline-maven-api:1421.v610fa_b_e2d60e pipeline-milestone-step:119.vdfdc43fc3b_9a_ pipeline-model-api:2.2214.vb_b_34b_2ea_9b_83 pipeline-model-definition:2.2214.vb_b_34b_2ea_9b_83 pipeline-model-extensions:2.2214.vb_b_34b_2ea_9b_83 pipeline-multibranch-defaults:2.1 pipeline-rest-api:2.34 pipeline-stage-step:312.v8cd10304c27a_ pipeline-stage-tags-metadata:2.2214.vb_b_34b_2ea_9b_83 pipeline-stage-view:2.34 pipeline-utility-steps:2.17.0 plain-credentials:183.va_de8f1dd5a_2b_ plugin-util-api:5.1.0 postgresql-api:42.7.2-40.v76d376d65c77 prism-api:1.29.0-17 pubsub-light:1.18 purge-job-history:1.6 remote-file:1.24 resource-disposer:0.23 role-strategy:743.v142ea_b_d5f1d3 scm-api:696.v778d637b_a_762 script-security:1362.v67dc1f0e1b_b_3 snakeyaml-api:2.3-123.v13484c65210a_ sonar:2.17.2 splunk-devops:1.10.1 splunk-devops-extend:1.10.1 sse-gateway:1.27 ssh-credentials:343.v884f71d78167 ssh-slaves:2.973.v0fa_8c0dea_f9f ssh-steps:2.0.68.va_d21a_12a_6476 sshd:3.330.vc866a_8389b_58 structs:338.v848422169819 text-file-operations:1.3.2 timestamper:1.27 token-macro:400.v35420b_922dcb_ trilead-api:2.147.vb_73cc728a_32e uno-choice:2.8.3 variant:60.v7290fc0eb_b_cd veracode-scan:24.2.23.0 workflow-aggregator:600.vb_57cdd26fdd7 workflow-api:1336.vee415d95c521 workflow-basic-steps:1058.vcb_fc1e3a_21a_9 workflow-cps:3969.vdc9d3a_efcc6a_ workflow-cps-global-lib:612.v55f2f80781ef workflow-durable-task-step:1371.vb_7cec8f3b_95e workflow-job:1436.vfa_244484591f workflow-multibranch:795.ve0cb_1f45ca_9a_ workflow-scm-step:427.v4ca_6512e7df1 workflow-step-api:678.v3ee58b_469476 workflow-support:926.v9f4f9b_b_98c19 ws-cleanup:0.46 ```What Operating System are you using (both controller, and any agents involved in the problem)?
This is on containerized Jenkins 2.462.2, using the latest available plugin version (710.v6f19df32544b_).
Reproduction steps
Expected Results
All projects scanned successfully, with no NPE.
Actual Results
The scanner fails due to an NPE on the base project, but the forked project succeeds:
Anything else?
No response
Are you interested in contributing a fix?
This is the code snippet in question:
Notice how there is no null-check for
gitlabProject.getForkedFromProject()
. A correct patch could be:The above would be correct because we (potentially) want to include MRs for non-forked projects, so if there's no fork, then this specific condition should not be evaluated.