Skip to content

Framework function to check an environment variable #5059

@ocaisa

Description

@ocaisa

In easybuilders/easybuild-easyblocks#4003, we ran into a case where os.getenv() was being used a little carelessly (not providing a default value which lead to a None being injected into the build command). In general I think a framework function would be useful for this to reduce/remove the need for generic testing. There are a couple of cases that would be nice to cover:

  • the environment variable may or may not exist (get_environment_variable("VAR"), returns value or '')
  • the environment variable must be defined (get_environment_variable("VAR", required=True), returns value or errors)
  • the environment variable if exists should be non-empty (get_environment_variable("VAR", empty=False))
  • the environment variable should exist and be non-empty (get_environment_variable("VAR", empty=False, required=True))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions