Set default value for environment variable when not already set

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      We'd like to set an environment variable for a pipeline job to inherit from a global environment variable when present, but to default to a reasonable value when not. This was possible in scripted pipeline using the following snippet:

       

      def foo = env.FOO ?: 'foo'
      withEnv(["BAR=${foo}"]) {
        // build
      }

      My attempts to recreate this in declarative pipelines have proven unsuccessful. If this is already possible, please provide some documentation. If it's not possible, please consider this a feature request.

       

            Assignee:
            Andrew Bayer
            Reporter:
            Dave Hunt
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: