0

I am new to DevOps and this whole world, so I would like some help.

I have an existing pipeline created. I also have a python script that I have just created, this script gets a json file, replace some stuff and replace the file content (I tested with a local file). Now I need to add this python code to my pipeline tasks, this task should copy a repository file, and process it.

I Googled trying to find a way of achiving this, but nothing. I do not even know where to place the python script.

Would anyone be able to point me to some direction?

Thank you very much.

RNA
  • 63
  • 2
  • 8

1 Answers1

1

You can put the python script file in Azure Git Repository and use the repository as the pipeline source. Then add Run a Python script task in pipeline and specify the script path like below.

enter image description here

To run Python scripts in your repository, you can also use a script element and specify a filename in YAML pipeline. For example:

- script: python src/example.py
Vita Zhang-MSFT
  • 246
  • 1
  • 4
  • Vita, thanks for your answer, do you know how I can then reference a group variable? I tried multiple ways, but it is not working $(var_name) $(VAR_NAME) $(env:var_name) $(env:VAR_NAME) – RNA Dec 23 '22 at 09:55
  • Hi RNA, you can refer to the documents [Define variables - Azure Pipelines](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch) and [use variables in variable group](https://learn.microsoft.com/en-us/azure/devops/pipelines/scripts/cli/pipeline-variable-group-secret-nonsecret-variables?view=azure-devops) to learn details. – Vita Zhang-MSFT Dec 26 '22 at 05:46