Search code examples
azureazure-devopspipelineapim

Run python script in a CI/CD step


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.


Solution

  • 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