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

Environment variables cross references aren't supported

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Unlike documented here https://github.com/jenkinsci/pipeline-model-definition-plugin/wiki/Syntax-Reference such sample doesn't work

          environment {
              FOO = "bar"
              OTHER = "${FOO}baz"
          }
      

      Firstly ${FOO} cannot work it is a groovy variable and it should be escaped

      OTHER = "\${FOO}baz"
      

      or

      OTHER = '${FOO}baz'
      

      And even by escaping it it's not working

      and we have

      [declarative-pipeline] Running shell script
      + printenv
      ...
      OTHER=nullbaz
      ...
      FOO=bar
      ...
      

      note that FOO is seen as null which makes no sense in shell env (it should be empty if unknown.

      cc Andrew BayerJesse Glickrsandell (should it be considered as a bug ? Or an improvement to do ?)

        Attachments

          Issue Links

            Activity

            Hide
            aheritier Arnaud Héritier added a comment - - edited

            Environment :

            docker-workflow:1.9.1:not-pinned
            pipeline-aggregator-view:1.4.1:not-pinned
            pipeline-build-step:2.4:not-pinned
            pipeline-github-lib:1.0:not-pinned
            pipeline-graph-analysis:1.3:not-pinned
            pipeline-input-step:2.5:not-pinned
            pipeline-milestone-step:1.3:not-pinned
            pipeline-model-api:1.0:not-pinned
            pipeline-model-declarative-agent:1.0:not-pinned
            pipeline-model-definition:1.0:not-pinned
            pipeline-rest-api:2.4:not-pinned
            pipeline-stage-step:2.2:not-pinned
            pipeline-stage-tags-metadata:1.0:not-pinned
            pipeline-stage-view:2.4:not-pinned
            pipeline-utility-steps:1.2.2:not-pinned
            workflow-aggregator:2.5:not-pinned
            workflow-api:2.8:not-pinned
            workflow-basic-steps:2.3:not-pinned
            workflow-cps:2.25:not-pinned
            workflow-cps-global-lib:2.5:not-pinned
            workflow-durable-task-step:2.8:not-pinned
            workflow-job:2.9:not-pinned
            workflow-multibranch:2.12:not-pinned
            workflow-scm-step:2.3:not-pinned
            workflow-step-api:2.8:not-pinned
            workflow-support:2.12:not-pinned
            

            On Jenkins ver. 2.32.1

            Show
            aheritier Arnaud Héritier added a comment - - edited Environment : docker-workflow:1.9.1:not-pinned pipeline-aggregator-view:1.4.1:not-pinned pipeline-build-step:2.4:not-pinned pipeline-github-lib:1.0:not-pinned pipeline-graph-analysis:1.3:not-pinned pipeline-input-step:2.5:not-pinned pipeline-milestone-step:1.3:not-pinned pipeline-model-api:1.0:not-pinned pipeline-model-declarative-agent:1.0:not-pinned pipeline-model-definition:1.0:not-pinned pipeline- rest -api:2.4:not-pinned pipeline-stage-step:2.2:not-pinned pipeline-stage-tags-metadata:1.0:not-pinned pipeline-stage-view:2.4:not-pinned pipeline-utility-steps:1.2.2:not-pinned workflow-aggregator:2.5:not-pinned workflow-api:2.8:not-pinned workflow-basic-steps:2.3:not-pinned workflow-cps:2.25:not-pinned workflow-cps-global-lib:2.5:not-pinned workflow-durable-task-step:2.8:not-pinned workflow-job:2.9:not-pinned workflow-multibranch:2.12:not-pinned workflow-scm-step:2.3:not-pinned workflow-step-api:2.8:not-pinned workflow-support:2.12:not-pinned On Jenkins ver. 2.32.1
            Hide
            rsandell rsandell added a comment - - edited

            does

            environment {
                    FOO = "bar"
                    OTHER = "$FOObaz"
            }
            

            work? since that should be fixed in the latest pipeline release iirc.

            Show
            rsandell rsandell added a comment - - edited does environment { FOO = "bar" OTHER = "$FOObaz" } work? since that should be fixed in the latest pipeline release iirc.
            Hide
            aheritier Arnaud Héritier added a comment -

            nope.

            [Pipeline] End of Pipeline
            groovy.lang.MissingPropertyException: No such property: FOObaz for class: groovy.lang.Binding
            	at groovy.lang.Binding.getVariable(Binding.java:63)
            

            It tries to find a groovy FOObaz var

            I'm attaching the job config file to easily reproduce it

            Show
            aheritier Arnaud Héritier added a comment - nope. [Pipeline] End of Pipeline groovy.lang.MissingPropertyException: No such property: FOObaz for class: groovy.lang.Binding at groovy.lang.Binding.getVariable(Binding.java:63) It tries to find a groovy FOObaz var I'm attaching the job config file to easily reproduce it
            Hide
            abayer Andrew Bayer added a comment -

            PR up at https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/110.

            This will require either using single-quotes or escaping dollar signs - I don't think I can get around that.

            Show
            abayer Andrew Bayer added a comment - PR up at https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/110 . This will require either using single-quotes or escaping dollar signs - I don't think I can get around that.
            Hide
            aheritier Arnaud Héritier added a comment -

            not a problem from my POV

            Show
            aheritier Arnaud Héritier added a comment - not a problem from my POV

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                aheritier Arnaud Héritier
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: