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

Environment variables cross references aren't supported

    XMLWordPrintable

Details

    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 abayerjglickrsandell (should it be considered as a bug ? Or an improvement to do ?)

      Attachments

        Issue Links

          Activity

            aheritier Arnaud Héritier created issue -
            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

            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
            rsandell rsandell added a comment - - edited

            does

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

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

            rsandell rsandell added a comment - - edited does environment { FOO = "bar" OTHER = "$FOObaz" } work? since that should be fixed in the latest pipeline release iirc.
            aheritier Arnaud Héritier made changes -
            Field Original Value New Value
            Attachment config.xml [ 35777 ]

            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

            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
            abayer Andrew Bayer made changes -
            Link This issue is duplicated by JENKINS-41890 [ JENKINS-41890 ]
            abayer Andrew Bayer made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            abayer Andrew Bayer made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            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.

            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.
            abayer Andrew Bayer made changes -
            Remote Link This issue links to "PR #110 (Web Link)" [ 15420 ]
            abayer Andrew Bayer made changes -
            Link This issue is duplicated by JENKINS-41386 [ JENKINS-41386 ]

            not a problem from my POV

            aheritier Arnaud Héritier added a comment - not a problem from my POV
            abayer Andrew Bayer made changes -
            Link This issue is duplicated by JENKINS-41623 [ JENKINS-41623 ]
            abayer Andrew Bayer made changes -
            Link This issue is duplicated by JENKINS-42666 [ JENKINS-42666 ]
            abayer Andrew Bayer made changes -
            Resolution Fixed [ 1 ]
            Status In Review [ 10005 ] Resolved [ 5 ]
            cloudbees CloudBees Inc. made changes -
            Remote Link This issue links to "CloudBees Internal OSS-1973 (Web Link)" [ 18490 ]
            cloudbees CloudBees Inc. made changes -
            Remote Link This issue links to "CloudBees Internal OSS-1935 (Web Link)" [ 18506 ]
            bitwiseman Liam Newman added a comment -

            Bulk closing resolved issues.

            bitwiseman Liam Newman added a comment - Bulk closing resolved issues.
            bitwiseman Liam Newman made changes -
            Status Resolved [ 5 ] Closed [ 6 ]

            People

              abayer Andrew Bayer
              aheritier Arnaud Héritier
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: