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

Unable to create variable with TEST in them [Declarative Pipeline - environment section]

XMLWordPrintable

      I would like to keep track of BRANCH within pipeline and build certain stages for certain branches. For this purpose I defined a variable TEST_BRANCH='develop', but I get error :

      groovy.lang.MissingPropertyException: No such property: TEST_BRANCH for class: groovy.lang.Binding
      at groovy.lang.Binding.getVariable(Binding.java:63)

      I thought I am not allowed to start variable name with TEST so I renamed the variable to BRANCH_TEST but I am still getting the same error. Can someone please clarify if there are any restriction on naming variables inside the environment section of pipeline.

      pipeline
      {
      agent any

      environment //Used within the pipeline

      { GIT_COMMIT = '' GIT_PROJECT = 'abc' GIT_REPO = 'repo1' APP_NAME = 'repo1' SERVER_NAME = 'xyz-web' GIT_BRANCH = env.BRANCH_NAME ?: 'develop' BRANCH_TEST = 'develop' ... }

      ...
      }

            abayer Andrew Bayer
            maqboolzee Zee Maqbool
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: