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

gerritReview only seems to allow Verified label

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • None

      The following pipeline code cannot parse "Code-Review" as a valid label when I try to execute the pipeline using the Gerrit-Code-Review plugin with Multi-branch project. Do i have to register new labels with the plugin somehow? Gerrit already has this label and a different (closely related project) uses Gerrit Trigger without any issues.

      post {
       success {
       gerritReview labels: [Code-Review: 0]
       }
       failure {
       gerritReview labels: [Code-Review: -1]
       }
      }

      If I run my Jenkinsfile with "Verified" instead, it attempts to contact Gerrit, but Gerrit refuses since I don't use a Verified label in our Gerrit (Only Code-Review and Document-Review).

      Here is the error I get when using "Code-Review":

      13:47:54 Seen 1,185 remote branches
       13:47:58 Obtained Jenkinsfile from 4a2af6b6fa40a83a200adb259f0bc31a7ebe753c
       13:47:58 Running in Durability level: MAX_SURVIVABILITY
       13:47:58 org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
       13:47:58 WorkflowScript: 137: expecting '}', found ':' @ line 137, column 26.
       13:47:58 gerritReview labels: [Code-Review: 0]
       13:47:58 ^
       13:47:58 
       13:47:58 1 error
       13:47:58 
       13:47:58 at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
       13:47:58 at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:150)
       13:47:58 at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:120)
       13:47:58 at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:132)
       13:47:58 at org.codehaus.groovy.control.SourceUnit.addError(SourceUnit.java:350)
       13:47:58 at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:144)
       13:47:58 at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:110)
       13:47:58 at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:234)
       13:47:58 at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:168)
       13:47:58 at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:943)
       13:47:58 at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:605)
       13:47:58 at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
       13:47:58 at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
       13:47:58 at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
       13:47:58 at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
       13:47:58 at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
       13:47:58 at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
       13:47:58 at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:142)
       13:47:58 at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127)
       13:47:58 at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:561)
       13:47:58 at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:522)
       13:47:58 at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:337)
       13:47:58 at hudson.model.ResourceController.execute(ResourceController.java:97)
       13:47:58 at hudson.model.Executor.run(Executor.java:428)
       13:47:58 Finished: FAILURE

      When I simply swap "Code-Review" for "Verified", the error changes to this (as expected since I don't have a Verified label configured):

      12:54:45 [Pipeline] gerritReview
       12:54:48 Gerrit review change 21476/20 labels
      {Verified=-1}
      ()
       12:54:48 Error when executing failure post condition:
       12:54:48 com.urswolfer.gerrit.client.rest.http.HttpStatusException: Request not successful. Message: Bad Request. Status-Code: 400. Content: label "Verified" is not a configured label.
       12:54:48 at com.urswolfer.gerrit.client.rest.http.GerritRestClient.throwHttpStatusException(GerritRestClient.java:517)
       12:54:48 at com.urswolfer.gerrit.client.rest.http.GerritRestClient.checkStatusCodeError(GerritRestClient.java:504)
       12:54:48 at com.urswolfer.gerrit.client.rest.http.GerritRestClient.checkStatusCodeClientError(GerritRestClient.java:490)
       12:54:48 at com.urswolfer.gerrit.client.rest.http.GerritRestClient.checkStatusCode(GerritRestClient.java:482)
       12:54:48 at com.urswolfer.gerrit.client.rest.http.GerritRestClient.request(GerritRestClient.java:254)
       12:54:48 at com.urswolfer.gerrit.client.rest.http.GerritRestClient.requestRest(GerritRestClient.java:182)
       12:54:48 at com.urswolfer.gerrit.client.rest.http.GerritRestClient.requestRest(GerritRestClient.java:174)
       12:54:48 at com.urswolfer.gerrit.client.rest.http.GerritRestClient.requestJson(GerritRestClient.java:151)
       12:54:48 at com.urswolfer.gerrit.client.rest.http.GerritRestClient.postRequest(GerritRestClient.java:130)
       12:54:48 at com.urswolfer.gerrit.client.rest.http.changes.RevisionApiRestClient.review(RevisionApiRestClient.java:86)
       12:54:48 at jenkins.plugins.gerrit.workflow.GerritReviewStep$Execution.run(GerritReviewStep.java:90)
       12:54:48 at jenkins.plugins.gerrit.workflow.GerritReviewStep$Execution.run(GerritReviewStep.java:43)
       12:54:48 at org.jenkinsci.plugins.workflow.steps.SynchronousStepExecution.start(SynchronousStepExecution.java:38)
       12:54:48 at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:286)
       12:54:48 at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:179)
       12:54:48 at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
       12:54:48 at sun.reflect.GeneratedMethodAccessor817.invoke(Unknown Source)
       12:54:48 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       12:54:48 at java.lang.reflect.Method.invoke(Method.java:498)
       12:54:48 at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
       12:54:48 at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
       12:54:48 at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
       12:54:48 at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
       12:54:48 at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
       12:54:48 at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
       12:54:48 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
       12:54:48 at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:163)
       12:54:48 at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
       12:54:48 at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:157)
       12:54:48 at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:161)
       12:54:48 at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:165)
       12:54:48 at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:135)
       12:54:48 at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
       12:54:48 at WorkflowScript.run(WorkflowScript:142)
       12:54:48 at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.delegateAndExecute(ModelInterpreter.groovy:137)
       12:54:48 at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.runPostConditions(ModelInterpreter.groovy:756)
       12:54:48 at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.catchRequiredContextForNode(ModelInterpreter.groovy:395)
       12:54:48 at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.catchRequiredContextForNode(ModelInterpreter.groovy:393)
       12:54:48 at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.runPostConditions(ModelInterpreter.groovy:755)
       12:54:48 at com.cloudbees.groovy.cps.CpsDefaultGroovyMethods.each(CpsDefaultGroovyMethods:2030)
       12:54:48 at com.cloudbees.groovy.cps.CpsDefaultGroovyMethods.each(CpsDefaultGroovyMethods:2015)
       12:54:48 at com.cloudbees.groovy.cps.CpsDefaultGroovyMethods.each(CpsDefaultGroovyMethods:2056)
       12:54:48 at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.runPostConditions(ModelInterpreter.groovy:745)
       12:54:48 at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.runPostConditions(ModelInterpreter.groovy)
       12:54:48 at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.executePostBuild(ModelInterpreter.groovy:723)
       12:54:48 at __cps.transform__(Native Method)
       12:54:48 at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86)
       12:54:48 at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
       12:54:48 at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
       12:54:48 at sun.reflect.GeneratedMethodAccessor578.invoke(Unknown Source)
       12:54:48 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       12:54:48 at java.lang.reflect.Method.invoke(Method.java:498)
       12:54:48 at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
       12:54:48 at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55)
       12:54:48 at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45)
       12:54:48 at sun.reflect.GeneratedMethodAccessor581.invoke(Unknown Source)
       12:54:48 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       12:54:48 at java.lang.reflect.Method.invoke(Method.java:498)
       12:54:48 at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
       12:54:48 at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55)
       12:54:48 at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45)
       12:54:48 at sun.reflect.GeneratedMethodAccessor581.invoke(Unknown Source)
       12:54:48 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       12:54:48 at java.lang.reflect.Method.invoke(Method.java:498)
       12:54:48 at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
       12:54:48 at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
       12:54:48 at com.cloudbees.groovy.cps.Next.step(Next.java:83)
       12:54:48 at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
       12:54:48 at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
       12:54:48 at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
       12:54:48 at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
       12:54:48 at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
       12:54:48 at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
       12:54:48 at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
       12:54:48 at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185)
       12:54:48 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:400)
       12:54:48 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:96)
       12:54:48 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:312)
       12:54:48 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:276)
       12:54:48 at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
       12:54:48 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       12:54:48 at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
       12:54:48 at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
       12:54:48 at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
       12:54:48 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
       12:54:48 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       12:54:48 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
       12:54:48 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
       12:54:48 at java.lang.Thread.run(Thread.java:748)
       12:54:48 
       12:54:48 [Pipeline] }
       12:54:48 [Pipeline] // stage
       12:54:48 [Pipeline] }
       12:54:48 [Pipeline] // withEnv
       12:54:48 [Pipeline] }
       12:54:48 [Pipeline] // node
       12:54:48 [Pipeline] End of Pipeline
       12:54:48 ERROR: Error cloning remote repo 'origin'
       12:54:48 Finished: FAILURE
      

       
      Here is an example of my Gerrit with Code-Review label:

            lucamilanesio Luca Domenico Milanesio
            olssons Sten Olsson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: