@@ -1662,16 +1662,6 @@ def __init__(
1662
1662
1663
1663
self ._initialize_data_directory ()
1664
1664
1665
- # Store 'environment' and 'environment-file' keys content
1666
- self ._environment = tmt .utils .environment_from_spec (
1667
- raw_fmf_environment_files = node .get ("environment-file" ) or [],
1668
- raw_fmf_environment = node .get ('environment' , {}),
1669
- raw_cli_environment_files = self .opt ('environment-file' ) or [],
1670
- raw_cli_environment = self .opt ('environment' ),
1671
- file_root = Path (node .root ) if node .root else None ,
1672
- key_address = node .name ,
1673
- logger = self ._logger )
1674
-
1675
1665
self ._plan_environment : EnvironmentType = {}
1676
1666
1677
1667
# Expand all environment and context variables in the node
@@ -1732,13 +1722,27 @@ def draw_test_serial_number(self, test: Test) -> int:
1732
1722
1733
1723
@property
1734
1724
def environment (self ) -> EnvironmentType :
1735
- """ Return combined environment from plan data and command line """
1725
+ """ Return combined environment from plan data, command line and original plan """
1726
+
1727
+ # Store 'environment' and 'environment-file' keys content
1728
+ environment_from_spec = tmt .utils .environment_from_spec (
1729
+ raw_fmf_environment_files = self .node .get ("environment-file" ) or [],
1730
+ raw_fmf_environment = self .node .get ('environment' , {}),
1731
+ raw_cli_environment_files = self .opt ('environment-file' ) or [],
1732
+ raw_cli_environment = self .opt ('environment' ),
1733
+ file_root = Path (self .node .root ) if self .node .root else None ,
1734
+ key_address = self .node .name ,
1735
+ logger = self ._logger )
1736
+
1737
+ # If this is an imported plan, update it with local environment stored in the original plan
1738
+ environment_from_original_plan = {}
1739
+ if self ._original_plan :
1740
+ environment_from_original_plan = self ._original_plan .environment
1741
+
1736
1742
if self .my_run :
1737
1743
combined = self ._plan_environment .copy ()
1738
- combined .update (self ._environment )
1739
- # Include environment of the importing plan
1740
- if self ._original_plan is not None :
1741
- combined .update (self ._original_plan .environment )
1744
+ combined .update (environment_from_spec )
1745
+ combined .update (environment_from_original_plan )
1742
1746
# Command line variables take precedence
1743
1747
combined .update (self .my_run .environment )
1744
1748
# Include path to the plan data directory
@@ -1751,7 +1755,8 @@ def environment(self) -> EnvironmentType:
1751
1755
# And tmt version
1752
1756
combined ["TMT_VERSION" ] = tmt .__version__
1753
1757
return combined
1754
- return self ._environment
1758
+
1759
+ return {** environment_from_spec , ** environment_from_original_plan }
1755
1760
1756
1761
def _source_plan_environment_file (self ) -> None :
1757
1762
""" Add variables from the plan environment file to the environment """
@@ -2443,8 +2448,6 @@ def import_plan(self) -> Optional['Plan']:
2443
2448
self ._imported_plan = Plan (node = node , run = self .my_run , logger = self ._logger )
2444
2449
self ._imported_plan ._original_plan = self
2445
2450
2446
- # Update imported plan environment with the local environment
2447
- self ._imported_plan .environment .update (self .environment )
2448
2451
with tmt .utils .modify_environ (self .environment ):
2449
2452
expand_node_data (node .data , {
2450
2453
key : ',' .join (value )
0 commit comments