GitHub: Could not match URL

Article ID:4404658899227
2 minute readKnowledge base

Issue

  • When using the GitHub plugin, if jobs mix both GitHub and non-GitHub repositories (e.g. the job source code is in GitHub and pipeline shared libraries are in another source code management platform), Jenkins logs are polluted with warnings like the following:

Jul 21, 2021 1:07:21 PM com.cloudbees.jenkins.GitHubRepositoryName create
WARNING: Could not match URL https://REPOSITORY_URL.git

Explanation

In the following example it is shown a pipeline job Job with Pipeline from SCM option pointing to a GitHub repository with a Jenkinsfile that also checkout a non-GitHub repository:

pipeline {
    agent any
    triggers {
        githubPush()
    }
    stages {
        stage ('Checkout') {
            steps {
                checkout scm
            }
        }
        stage ('Checkout non-GitHub SCM') {
            steps {
                checkout(
                    changelog: false,
                    poll: false,
                    scm: [$class: 'GitSCM',
                          branches: [[name: '*/main']],
                          userRemoteConfigs: [[
                              credentialsId: '<scmCredentials>',
                              url: '<nonGitHubRepo>'
                          ]]
                    ]
                )
            }
        }
    }
}

After building it once, if a webhook in GitHub for push event to $JENKINS_URL/github-webhook/ is created and a new code change is made, then the instance logs will start to show the warning log message described in the issue section.

Resolution

A pull request has been made at the GitHub plugin repository: github-plugin#251

Workaround

Modify the log level for com.cloudbees.jenkins.GitHubRepositoryName to ERROR or SEVERE following the guide: Configure Loggers for Jenkins