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

ClassCastException: when using double quotes labels in the restrict where to run textbox

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: core
    • Labels:
      None
    • Environment:
      Jenkins 2.60.3
      Jenkins 1.607
    • Similar Issues:

      Description

      Hi there,

      I've seen the below stacktrace:

      Caused by: java.lang.ClassCastException: hudson.model.labels.LabelExpression$And cannot be cast to hudson.model.labels.LabelAtom

      Which it's caused when using doublequotes restricted labels:

       

      When I debugged I saw the below details:

      Unfortunately I wasn't able to reproduce in my test scenario with something like:

      @Test public void testWithDoubleQuoteAssignedLabel() throws Exception {
          FreeStyleProject project = j.createFreeStyleProject();
          j.createSlave("test",null);
          project.setAssignedLabel(j.jenkins.getLabel("\"linux && !reserved\""));
          assertFalse(checker.executeCheck(project));
      }

       

      It looks like it is caused by: https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/AbstractProject.java#L413  and when configuring jobs using the WebUI. 

       

      Workaround: 

      • If i use "getAssignedLabel().getName()" I don't see that error...

       

      Please find attached the maven dependencies tree

      If you need further details please let me know

       

      Thanks

       

        Attachments

          Activity

          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Victor Martinez
          Path:
          src/main/java/org/jenkins/ci/plugins/jenkinslint/check/JobAssignedLabelChecker.java
          http://jenkins-ci.org/commit/jenkinslint-plugin/f2bd2b0e8b5e192b58eeb34cc7d96ae572ad29f3
          Log:
          JENKINS-46383 using getAssignedLabel since .getAssignedLabelString causes issues when using wrong formatted doublequote restriction labels within the WebUI

          Change-Id: I7a5703ec2ae3964e946e3cf883bc6531537b08a7

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Victor Martinez Path: src/main/java/org/jenkins/ci/plugins/jenkinslint/check/JobAssignedLabelChecker.java http://jenkins-ci.org/commit/jenkinslint-plugin/f2bd2b0e8b5e192b58eeb34cc7d96ae572ad29f3 Log: JENKINS-46383 using getAssignedLabel since .getAssignedLabelString causes issues when using wrong formatted doublequote restriction labels within the WebUI Change-Id: I7a5703ec2ae3964e946e3cf883bc6531537b08a7
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Victor Martinez
          Path:
          src/main/java/org/jenkins/ci/plugins/jenkinslint/check/JobAssignedLabelChecker.java
          http://jenkins-ci.org/commit/jenkinslint-plugin/adbacb84396e5d7691f5f29e407bb107902c405f
          Log:
          JENKINS-46383 using getAssignedLabel since .getAssignedLabelString causes issues when using wrong formatted doublequote restriction labels within the WebUI

          Change-Id: I7a5703ec2ae3964e946e3cf883bc6531537b08a7

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Victor Martinez Path: src/main/java/org/jenkins/ci/plugins/jenkinslint/check/JobAssignedLabelChecker.java http://jenkins-ci.org/commit/jenkinslint-plugin/adbacb84396e5d7691f5f29e407bb107902c405f Log: JENKINS-46383 using getAssignedLabel since .getAssignedLabelString causes issues when using wrong formatted doublequote restriction labels within the WebUI Change-Id: I7a5703ec2ae3964e946e3cf883bc6531537b08a7
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Victor Martinez
          Path:
          pom.xml
          src/main/java/org/jenkins/ci/plugins/jenkinslint/JenkinsLintAction.java
          src/main/java/org/jenkins/ci/plugins/jenkinslint/check/GroovySandboxChecker.java
          src/main/java/org/jenkins/ci/plugins/jenkinslint/check/GroovySystemExitChecker.java
          src/main/java/org/jenkins/ci/plugins/jenkinslint/check/JobAssignedLabelChecker.java
          src/main/java/org/jenkins/ci/plugins/jenkinslint/graph/JenkinsLintGraph.java
          src/main/java/org/jenkins/ci/plugins/jenkinslint/model/AbstractAction.java
          src/main/java/org/jenkins/ci/plugins/jenkinslint/model/InterfaceCheck.java
          src/main/resources/org/jenkins/ci/plugins/jenkinslint/JenkinsLintAction/index.jelly
          src/test/java/org/jenkins/ci/plugins/jenkinslint/JenkinsLintGlobalConfigurationTestCase.java
          src/test/java/org/jenkins/ci/plugins/jenkinslint/check/RandomTestCase.java
          src/test/resources/org/jenkins/ci/plugins/jenkinslint/check/RandomTestCase/testDoubleQuoteLabels.zip
          src/test/resources/org/jenkins/ci/plugins/jenkinslint/check/RandomTestCase/testMultiJobWithNPEParameters.zip
          http://jenkins-ci.org/commit/jenkinslint-plugin/61abe7c4815d3e4bed0d512b3bca3e92eb3956f4
          Log:
          JENKINS-46350 Feature/graphs (#38)

          • Enabling Graph visualisation of the overall Lints

          Change-Id: I654aa0b41197bf9b0bdae52ac76b13effdd01984

          • Added PieCharts and refactored previous implementation

          Change-Id: I2271d13b8eb682f7fdebf0e460ac8faba7e8d6cc

          • Fixed synchronised issues

          Change-Id: I4741c22f73389b82d05b9c7f0e16d5f6836b27e6

          • Added further test cases to test the current label
            classcastexception

          Apparently this is just caused with a combination of plugins which I've
          not found yet which it's the culprit

          Missing Unit Tests

          Change-Id: I6f65be3b44815e655c32b8f0e88bb5b85bcb8513

          • JENKINS-46383 using getAssignedLabel since .getAssignedLabelString causes issues when using wrong formatted doublequote restriction labels within the WebUI

          Change-Id: I7a5703ec2ae3964e946e3cf883bc6531537b08a7

          • Using different colours to show the severities and minor cosmetic changes

          Change-Id: I71e49b08105c4b5f1485344ae8f2b2e57ba3deb0

          • Removed unused imports

          Change-Id: I6a23e05bfffa2632a1c72f90354b14bc11481273

          • Unfortunately when empty it uses the default agent 'master'

          Change-Id: I7d3f610c91550fe5af53a8ee6fc46c0cd3d14d67

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Victor Martinez Path: pom.xml src/main/java/org/jenkins/ci/plugins/jenkinslint/JenkinsLintAction.java src/main/java/org/jenkins/ci/plugins/jenkinslint/check/GroovySandboxChecker.java src/main/java/org/jenkins/ci/plugins/jenkinslint/check/GroovySystemExitChecker.java src/main/java/org/jenkins/ci/plugins/jenkinslint/check/JobAssignedLabelChecker.java src/main/java/org/jenkins/ci/plugins/jenkinslint/graph/JenkinsLintGraph.java src/main/java/org/jenkins/ci/plugins/jenkinslint/model/AbstractAction.java src/main/java/org/jenkins/ci/plugins/jenkinslint/model/InterfaceCheck.java src/main/resources/org/jenkins/ci/plugins/jenkinslint/JenkinsLintAction/index.jelly src/test/java/org/jenkins/ci/plugins/jenkinslint/JenkinsLintGlobalConfigurationTestCase.java src/test/java/org/jenkins/ci/plugins/jenkinslint/check/RandomTestCase.java src/test/resources/org/jenkins/ci/plugins/jenkinslint/check/RandomTestCase/testDoubleQuoteLabels.zip src/test/resources/org/jenkins/ci/plugins/jenkinslint/check/RandomTestCase/testMultiJobWithNPEParameters.zip http://jenkins-ci.org/commit/jenkinslint-plugin/61abe7c4815d3e4bed0d512b3bca3e92eb3956f4 Log: JENKINS-46350 Feature/graphs (#38) Enabling Graph visualisation of the overall Lints Change-Id: I654aa0b41197bf9b0bdae52ac76b13effdd01984 Added PieCharts and refactored previous implementation Change-Id: I2271d13b8eb682f7fdebf0e460ac8faba7e8d6cc Fixed synchronised issues Change-Id: I4741c22f73389b82d05b9c7f0e16d5f6836b27e6 JENKINS-46424 Added testcases Added further test cases to test the current label classcastexception Apparently this is just caused with a combination of plugins which I've not found yet which it's the culprit JENKINS-46424 Fixed NullPointerException Missing Unit Tests Change-Id: I6f65be3b44815e655c32b8f0e88bb5b85bcb8513 JENKINS-46383 using getAssignedLabel since .getAssignedLabelString causes issues when using wrong formatted doublequote restriction labels within the WebUI Change-Id: I7a5703ec2ae3964e946e3cf883bc6531537b08a7 Using different colours to show the severities and minor cosmetic changes Change-Id: I71e49b08105c4b5f1485344ae8f2b2e57ba3deb0 Removed unused imports Change-Id: I6a23e05bfffa2632a1c72f90354b14bc11481273 Unfortunately when empty it uses the default agent 'master' Change-Id: I7d3f610c91550fe5af53a8ee6fc46c0cd3d14d67
          Hide
          v2v Victor Martinez added a comment -

          It looks like this particular issue is caused by a combination of certain plugins, I'll need to narrow down which one is causing it since I couldn't reproduce using the same Jenkins jobs and the UTH unfortunately. 

           

          I'll keep this thread open to provide as much details as possible.

          Show
          v2v Victor Martinez added a comment - It looks like this particular issue is caused by a combination of certain plugins, I'll need to narrow down which one is causing it since I couldn't reproduce using the same Jenkins jobs and the UTH unfortunately.    I'll keep this thread open to provide as much details as possible.

            People

            • Assignee:
              Unassigned
              Reporter:
              v2v Victor Martinez
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: