Could not fetch sources from navigator GitLabSCMNavigator error during scanning a folder after upgrading to 645.v62a_b_6fce8659
Jenkins and plugins versions report
Hello, @mifitous. I got following error after upgrade to 645.v62a_b_6fce8659 when I try to scan organization folder:
Environment
Jenkins: 2.382 Java: 11.0.17 GitLab CE 14.10
gitlab-api:5.0.1-78.v47a_45b_9f78b_7 gitlab-branch-source:645.v62a_b_6fce8659
What Operating System are you using (both controller, and any agents involved in the problem)?
OS: Linux
Reproduction steps
My JobDSL script
organizationFolder('my_project_build_entries') {
description("GitLab folder created with Job DSL")
displayName('my_project / build entries')
organizations {
gitLabSCMNavigator {
projectOwner("org/prj/my_project/build-entries")
credentialsId('gitlab-user-ssh-key')
serverName("Gitlaborg")
traits {
gitLabBranchDiscovery {
strategyId(1)
}
originMergeRequestDiscoveryTrait {
strategyId(1)
}
}
}
}
configure {
def traits = it / navigators / 'io.jenkins.plugins.gitlabbranchsource.GitLabSCMNavigator' / traits
traits << 'io.jenkins.plugins.gitlabbranchsource.ForkMergeRequestDiscoveryTrait' {
strategyId(1)
trust(class: 'io.jenkins.plugins.gitlabbranchsource.ForkMergeRequestDiscoveryTrait$TrustPermission')
}
traits << 'jenkins.scm.impl.trait.WildcardSCMHeadFilterTrait' {
includes('master dev MR-*')
excludes('')
}
}
projectFactories {
def remoteJenkinsFileGitUrl = 'ssh://[email protected]/orgdev/org-jenkins-jobs.git'
def remoteJenkinsFileGitBranchOption = "dev"
def remoteJenkinsFileGitRepoName = remoteJenkinsFileGitUrl.split('/')[-1].replace('.git', '')
def refSpecOption = "+refs/heads/${remoteJenkinsFileGitBranchOption}:refs/remotes/${remoteJenkinsFileGitRepoName}/${remoteJenkinsFileGitBranchOption}"
def branchSpecOption = "refs/heads/${remoteJenkinsFileGitBranchOption}"
remoteJenkinsFileWorkflowMultiBranchProjectFactory{
localMarker(".ci")
matchBranches(false)
remoteJenkinsFile("build-entries/pipeline.groovy")
remoteJenkinsFileSCM {
gitSCM {
branches{
branchSpec{
name(branchSpecOption)
}
}
userRemoteConfigs {
userRemoteConfig {
name(remoteJenkinsFileGitRepoName)
refspec(refSpecOption)
url(remoteJenkinsFileGitUrl)
credentialsId('gitlab-user-ssh-key')
}
browser{}
gitTool('')
extensions {
excludeFromChangeSet()
excludeFromPoll()
}
}
}
}
}
}
orphanedItemStrategy {
discardOldItems {
daysToKeep(10)
numToKeep(2)
}
}
triggers {
periodicFolderTrigger {
interval('1440m')
}
}
}
Expected Results
Scan without errors
Actual Results
Scan with errors
Could you check what might be causing this error on new version, please?
@coreegor : will have a look at it
Hi, we have the same issues with scaning.
ERROR: [Mon Dec 04 10:03:07 UTC 2023] Could not fetch sources from navigator io.jenkins.plugins.gitlabbranchsource.GitLabSCMNavigator [Mon Dec 04 10:03:07 UTC 2023] Finished organization scan. Scan took 1.2 sec FATAL: Failed to recompute children of REPO » REPO » REPO_deploy java.lang.NullPointerException at io.jenkins.plugins.gitlabbranchsource.GitLabHookCreator.isTokenEqual(GitLabHookCreator.java:231) at io.jenkins.plugins.gitlabbranchsource.GitLabHookCreator.createWebHookWhenMissing(GitLabHookCreator.java:222) at io.jenkins.plugins.gitlabbranchsource.GitLabSCMNavigator.visitSources(GitLabSCMNavigator.java:287) at jenkins.branch.OrganizationFolder.computeChildren(OrganizationFolder.java:536) at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:278) at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:166) at jenkins.branch.OrganizationFolder$OrganizationScan.run(OrganizationFolder.java:918) at hudson.model.ResourceController.execute(ResourceController.java:107) at hudson.model.Executor.run(Executor.java:449) Finished: FAILURE
@Mykola-Dziuba : Sorry, I'm no more working on this repo
Hi,
I try to analyzed the bug. I think this is here : https://github.com/jenkinsci/gitlab-branch-source-plugin/blob/62ab6fce865945ebbf0f5c2f7894c80551fe8888/src/main/java/io/jenkins/plugins/gitlabbranchsource/GitLabSCMNavigator.java#L288. The variable "webHookUrl" seems empty. But this change is not recent, more than 2 years. I found this code very complex to just log one thing. I don't understand all the code so I'm not sure what to do.
I would propose this code, this will not thrown the exception but the log will not be executed :
if (webhookGitLabApi != null && webHookUrl != null and ! webHookUrl.isEmpty()) {
observer.getListener().getLogger().format("Web hook %s%n", GitLabHookCreator
.createWebHookWhenMissing(webhookGitLabApi, projectPathWithNamespace,
webHookUrl, server.getSecretTokenAsPlainText()));
}
Hi @coreegor ,
I continue the analyze. Can you confirm in your Jenkins configuration that your server name "Gitlaborg" in your example if configured. And if the field "Root URL for hooks" is fulfill or not? Check if there are not white characters in it?
Maybe you're here : https://github.com/jenkinsci/gitlab-branch-source-plugin/blob/6f19df32544b29c2c2904fbaed206a281335a33b/src/main/java/io/jenkins/plugins/gitlabbranchsource/GitLabHookCreator.java#L184C13-L184C32 and the code fail later
@Turiok Sorry, but we no longer use this plugin and I have no way to test it. Should I close this ticket?
Hi @coreegor ,
I don't know if it's better to close or not Can you give me the issue? I'm going to test something and if it's not conclusive. I'll close it
Can I ask which plugin do you use to handle Gitlab merge request ?
@Turiok I don't see a way to change the reporter for this task. Right now I'm just using GitLab CI.
Hi @coreegor ,
I tested on my instance and can't reproduce this problem. If the custom root url is blank. It'll fail before when this method is called : https://github.com/jenkinsci/gitlab-branch-source-plugin/blob/6f19df32544b29c2c2904fbaed206a281335a33b/src/main/java/io/jenkins/plugins/gitlabbranchsource/GitLabSCMNavigator.java#L263
I think you could close this issue. Because it missing context of configuration of the server.
Hi @Mykola-Dziuba ,
Did you use the last version of this plugin? I found a commit, it seems to correct your problem : https://github.com/jenkinsci/gitlab-branch-source-plugin/commit/9241ae4a27da30f2a95088dd6a92d06b1ec2b7b0
If not, please create a new issue with your context and the problem
Thanks everyone! Closing the task.