-
Improvement
-
Resolution: Fixed
-
Minor
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.
- depends on
-
JENKINS-42753 Generate runtime model directly from AST model
-
- Closed
-
[JENKINS-45991] Set default value for environment variable when not already set
Labels | New: declarative-variable-and-method-resolution |
Epic Link |
New:
|
Link |
New:
This issue depends on |
Resolution | New: Fixed [ 1 ] | |
Status | Original: Open [ 1 ] | New: Resolved [ 5 ] |
Status | Original: Resolved [ 5 ] | New: Closed [ 6 ] |
A use case for this is specifying the number of parallel processes for pytest. This is done via a command line option set in an environment variable named PYTEST_ADDOPTS. A reasonable default is 'auto', which determines the number of processes based on the CPUs available on the system, however it would be beneficial to override this on a per-instance basis. The idea is that we'd set a PYTEST_PROCESSES environment variable, which takes precedence over the default of 'auto' defined in the pipeline.