summaryrefslogtreecommitdiff
path: root/test/lib
diff options
context:
space:
mode:
authorMatt Clay <mclay@redhat.com>2020-10-21 14:18:43 -0700
committerGitHub <noreply@github.com>2020-10-21 16:18:43 -0500
commitc54dc50bd7de1175efea2794f034685fa4082100 (patch)
tree1ccd2ca6ef53e845acc19d391668a9e1114b311a /test/lib
parent7529d31ba9042843ca4364459a744381728b7b4f (diff)
downloadansible-c54dc50bd7de1175efea2794f034685fa4082100.tar.gz
[stable-2.9] Fix ansible-test Azure Pipelines container auth. (#72283)
(cherry picked from commit 2ef4b7e07e6a47785544d0b195fe6887b5c4595b) Co-authored-by: Matt Clay <matt@mystile.com>
Diffstat (limited to 'test/lib')
-rw-r--r--test/lib/ansible_test/_internal/ci/azp.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/test/lib/ansible_test/_internal/ci/azp.py b/test/lib/ansible_test/_internal/ci/azp.py
index 1b7a6398bc..962e838e7c 100644
--- a/test/lib/ansible_test/_internal/ci/azp.py
+++ b/test/lib/ansible_test/_internal/ci/azp.py
@@ -151,8 +151,14 @@ class AzurePipelinesAuthHelper(CryptographyAuthHelper):
"""
def publish_public_key(self, public_key_pem): # type: (str) -> None
"""Publish the given public key."""
+ try:
+ agent_temp_directory = os.environ['AGENT_TEMPDIRECTORY']
+ except KeyError as ex:
+ raise MissingEnvironmentVariable(name=ex.args[0])
+
# the temporary file cannot be deleted because we do not know when the agent has processed it
- with tempfile.NamedTemporaryFile(prefix='public-key-', suffix='.pem', delete=False) as public_key_file:
+ # placing the file in the agent's temp directory allows it to be picked up when the job is running in a container
+ with tempfile.NamedTemporaryFile(prefix='public-key-', suffix='.pem', delete=False, dir=agent_temp_directory) as public_key_file:
public_key_file.write(to_bytes(public_key_pem))
public_key_file.flush()