Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-63572

Git checkout NullPointerException if no userRemoteConfig is provided (4.4.0)

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: git-plugin
    • Labels:
      None
    • Environment:
      git-plugin 4.4.0
    • Similar Issues:
    • Released As:
      git plugin 4.4.3

      Description

      Some of our builds started to fail during a checkout step with the following error:

      java.lang.NullPointerException
      	at hudson.plugins.git.GitSCM.createClient(GitSCM.java:852)
      	at hudson.plugins.git.GitSCM.createClient(GitSCM.java:833)
      	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1240)
      	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:125)
      	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:93)
      	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:80)
      	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      Finished: FAILURE
      

      The code, that used to work in the past, was configured (for some reasons) as follow:

          stage("Checkout branch") {
              checkout scm
              // Specific configuration to clone the branch into a dedicated local branch.
              checkout([$class    : 'GitSCM',
                        branches  : [[name: "*/${env.BRANCH_NAME}"]],
                        extensions: [[$class: 'LocalBranch', localBranch: env.BRANCH_NAME]]
              ])
          }
      

      It looks like this was introduced by a recent change in https://github.com/jenkinsci/git-plugin/pull/931, specifically in the following changeset: if getUserRemoteConfigs() doesn't return any "user remote config", then chooser stays null and the call to chooser.getGitTool() fails with a NullPointerException.

        Attachments

          Issue Links

            Activity

            Hide
            markewaite Mark Waite added a comment -

            You need to add userRemoteConfig into the checkout arguments, like this:

            stage('checkout') {
                        steps {
                            checkout([$class: 'GitSCM',  branches: [[name: "refs/tags/${VERSION}"]]. userRemoteConfigs: scm.userRemoteConfigs ],poll: false)
                        }
                    }
            

            In case it helps, I have a sample that uses the technique (though my sample does not disable polling like yours does).

            Show
            markewaite Mark Waite added a comment - You need to add userRemoteConfig into the checkout arguments, like this: stage('checkout') { steps { checkout([$class: 'GitSCM', branches: [[name: "refs/tags/${VERSION}"]]. userRemoteConfigs: scm.userRemoteConfigs ],poll: false) } } In case it helps, I have a sample that uses the technique (though my sample does not disable polling like yours does).
            Hide
            jaegger Ray Muggy added a comment -

            Mark Waite, thanks a lot. I try it now.

            Show
            jaegger Ray Muggy added a comment - Mark Waite , thanks a lot. I try it now.
            Hide
            jaegger Ray Muggy added a comment -

            Mark Waite, Ouppss. I get an exception at pipeline start :

            [Checks API] No suitable checks publisher found.
            org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
            WorkflowScript: 24: illegal colon after argument expression;
               solution: a complex label expression before a colon must be parenthesized @ line 24, column 106.
               VERSION}"]]. userRemoteConfigs: scm.user
                                             ^1 error	at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
            	at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:150)
            	at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:120)
            	at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:132)
            	at org.codehaus.groovy.control.SourceUnit.addError(SourceUnit.java:350)
            	at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:144)
            	at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:110)
            	at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:234)
            	at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:168)
            	at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:943)
            	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:605)
            	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
            	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
            	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
            	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
            	at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
            	at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
            	at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:142)
            	at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127)
            	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:571)
            	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:523)
            	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:337)
            	at hudson.model.ResourceController.execute(ResourceController.java:97)
            	at hudson.model.Executor.run(Executor.java:428)
            Finished: FAILURE
            

            Thanks

            Show
            jaegger Ray Muggy added a comment - Mark Waite , Ouppss. I get an exception at pipeline start : [Checks API] No suitable checks publisher found. org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: 24: illegal colon after argument expression; solution: a complex label expression before a colon must be parenthesized @ line 24, column 106. VERSION}"]]. userRemoteConfigs: scm.user ^1 error at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310) at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:150) at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:120) at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:132) at org.codehaus.groovy.control.SourceUnit.addError(SourceUnit.java:350) at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:144) at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:110) at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:234) at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:168) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:943) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:605) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688) at groovy.lang.GroovyShell.parse(GroovyShell.java:700) at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:142) at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127) at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:571) at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:523) at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:337) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:428) Finished: FAILURE Thanks
            Hide
            jaegger Ray Muggy added a comment -

            I change . to , before userRemoteConfig, but nothing right :

            org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
            WorkflowScript: 24: Arguments to "checkout" must be explicitly named. @ line 24, column 16.
                              checkout([$class: 'GitSCM',  branches: [[name: "refs/tags/${VERSION}"]], userRemoteConfigs: scm.userRemoteConfigs ],poll: false)
                              ^1 error	at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
            	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1085)
            	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
            	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
            	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
            	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
            	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
            	at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
            	at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
            	at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:142)
            	at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127)
            	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:571)
            	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:523)
            	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:337)
            	at hudson.model.ResourceController.execute(ResourceController.java:97)
            	at hudson.model.Executor.run(Executor.java:428)
            Finished: FAILURE
            
            Show
            jaegger Ray Muggy added a comment - I change . to , before userRemoteConfig , but nothing right : org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: 24: Arguments to "checkout" must be explicitly named. @ line 24, column 16. checkout([$class: 'GitSCM' , branches: [[name: "refs/tags/${VERSION}" ]], userRemoteConfigs: scm.userRemoteConfigs ],poll: false ) ^1 error at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310) at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1085) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688) at groovy.lang.GroovyShell.parse(GroovyShell.java:700) at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:142) at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127) at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:571) at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:523) at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:337) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:428) Finished: FAILURE
            Hide
            jaegger Ray Muggy added a comment -

            Mark Waite,

            I changed the "checkout" code with my old code and added userRemoteConfig, It works :

            stage('checkout') {
                        steps {
                           checkout scm: [$class: 'GitSCM',  branches: [[name: "refs/tags/${VERSION}"]], userRemoteConfigs: scm.userRemoteConfigs ],poll: false
                        }
                    }
            

            Thanks

            Show
            jaegger Ray Muggy added a comment - Mark Waite , I changed the "checkout" code with my old code and added userRemoteConfig, It works : stage( 'checkout' ) { steps { checkout scm: [$class: 'GitSCM' , branches: [[name: "refs/tags/${VERSION}" ]], userRemoteConfigs: scm.userRemoteConfigs ],poll: false } } Thanks

              People

              • Assignee:
                markewaite Mark Waite
                Reporter:
                multani Jonathan Ballet
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: