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

Globals not accessible in Declarative Pipeline outside script directive

      See https://github.com/jenkins-infra/jenkins.io/pull/611

      Basically, it was a design decision to not allow any form of thing.method() in Declarative. This was needed to support validation.

      It is possible to circumvent this in several ways and there are bugs that might address this, but it is a hard problem.

          [JENKINS-42360] Globals not accessible in Declarative Pipeline outside script directive

          Andrew Bayer added a comment -

          Note that globals are usable within script blocks.

          Andrew Bayer added a comment - Note that globals are usable within script blocks.

          Andrew Bayer added a comment -

          I've got a PR up at https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/127 with better error reporting of an object method call - doesn't enable usage of them, but does at least explain the error.

          Andrew Bayer added a comment - I've got a PR up at https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/127 with better error reporting of an object method call - doesn't enable usage of them, but does at least explain the error.

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/Messages.properties
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BasicModelDefTest.java
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java
          pipeline-model-definition/src/test/resources/libraryObjectDefinedOutsidePipeline.groovy
          pipeline-model-definition/src/test/resources/libraryObjectOutsideScript.groovy
          http://jenkins-ci.org/commit/pipeline-model-definition-plugin/2750f57fad326f173fb81012d522dfc7639197b3
          Log:
          JENKINS-42360 Improve validation on object method calls

          Actually distinguish object method calls from generalized "expected a
          symbol", and report accordingly.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/Messages.properties pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BasicModelDefTest.java pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java pipeline-model-definition/src/test/resources/libraryObjectDefinedOutsidePipeline.groovy pipeline-model-definition/src/test/resources/libraryObjectOutsideScript.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/2750f57fad326f173fb81012d522dfc7639197b3 Log: JENKINS-42360 Improve validation on object method calls Actually distinguish object method calls from generalized "expected a symbol", and report accordingly.

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/Messages.properties
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BasicModelDefTest.java
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java
          pipeline-model-definition/src/test/resources/libraryObjectDefinedOutsidePipeline.groovy
          pipeline-model-definition/src/test/resources/libraryObjectOutsideScript.groovy
          http://jenkins-ci.org/commit/pipeline-model-definition-plugin/5c215ff0cdbf81bb517d34451aeb5d6a32fe7044
          Log:
          Merge pull request #127 from abayer/jenkins-42360

          JENKINS-42360 Improve validation on object method calls

          Compare: https://github.com/jenkinsci/pipeline-model-definition-plugin/compare/faa4b12cea65...5c215ff0cdbf

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/Messages.properties pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BasicModelDefTest.java pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java pipeline-model-definition/src/test/resources/libraryObjectDefinedOutsidePipeline.groovy pipeline-model-definition/src/test/resources/libraryObjectOutsideScript.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/5c215ff0cdbf81bb517d34451aeb5d6a32fe7044 Log: Merge pull request #127 from abayer/jenkins-42360 JENKINS-42360 Improve validation on object method calls Compare: https://github.com/jenkinsci/pipeline-model-definition-plugin/compare/faa4b12cea65...5c215ff0cdbf

          Andrew Bayer added a comment -

          fyi, this was resolved because the validation improvements are all we're gonna do here - we're not actually going to allow the behavior, but now we're erroring out on more of it, at least.

          Andrew Bayer added a comment - fyi, this was resolved because the validation improvements are all we're gonna do here - we're not actually going to allow the behavior, but now we're erroring out on more of it, at least.

          Liam Newman added a comment -

          Bulk closing resolved issues.

          Liam Newman added a comment - Bulk closing resolved issues.

            abayer Andrew Bayer
            bitwiseman Liam Newman
            Votes:
            2 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: