Passing azure secret variables to pytest in pipeline

0 votes

We are using Azure Pipeline to run Python integration tests. 

These tests make use of a database, and the login information is saved in an Azure variable group that also contains secret variables. 

The integration tests are started in this section of the yaml file:

jobs:
- job: IntegrationTests
  variables:
    - group: <some_variable_group>

 - script: |
       pdm run pytest \
         --variables "$VARIABLE_FILE" \
         --test-run-title="$TEST_TITLE" \
         --napoleon-docstrings \
         --doctest-modules \
         --color=yes \
         --junitxml=junit/test-results.xml \
         integration

     env:
       DB_USER: $(SMDB_USER)
       DB_PASSWORD: $(SMDB_PASSWORD)
       DB_HOST: $(SMDB_HOST)
       DB_DATABASE: $(SMDB_DATABASE)

The issue is that because SMDB PASSWORD is a secret variable, we are unable to read its value. It is advised to use arguments in a PythonScript task (like here: Passing arguments to python script in Azure Devops) in order to use the secret variables, but I am unsure of how to change this script to define PythonScript since it uses pdm.

Feb 7, 2023 in DevOps on Cloud by Damonlang
• 1,230 points

edited 4 days ago 95 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP