azure-devopsazure-pipelinesazure-task-groups

Where can we specify Github repository path in Tasks in Azure Devops?


I have created a task group to run robot framework scripts in Azure DevOps. I have added below tasks to the task group:

  1. Use Python version
  2. Python script to install robot framework
  3. Python script task to run robot framework script
  4. Publish Test Results

In the task Python script task to run robot framework script, I have the following inline script:

pip install pytest pytest-azurepipelines
pytest
robot --pythonpath . -x outputxunit.xml TestScenarios.robot

TestScenarios.robot is present in my GitHub repository. So my question is where can I specify that TestScenarios.robot needs to be picked up from my GitHub repository. I am unable to figure out how to do that in the tasks. I know that when setting up a pipeline, we have a configuration option, where we can specify the GitHub repository. But I want to know how we can provide GitHub repository details to the task? I then want to use this task group in my stage release, so that whenever we deploy a release, the task group will be triggered to run the automation script. Let me know if you need more details.


Solution

  • For Build Pipeline:

    When the build start, the source repo will be downloaded to $(Build.SourcesDirectory).

    So you could specify the repo path as $(Build.SourcesDirectory)/Scriptfolder/xx.robot.

    Here is my example:

    The xx.robot is in ScriptFolder.

    enter image description here

    The robot framework script:

    robot --pythonpath . -x outputxunit.xml $(build.sourcesdirectory)/ScriptFolder/TestCases.robot
    

    For Release Pipeline

    In Release, the source will be downloaded to $(System.ArtifactsDirectory)/{Source alias }

    Note: the Source alias is in Release definition -> Artifacts.

    enter image description here

    Here is my script example:

    robot --pythonpath . -x outputxunit.xml $(System.ArtifactsDirectory)/_lujinlou_TestPython/ScriptFolder/TestCases.robot
    

    Here are the docs about Build Variables and Release Variables.

    Update:

    Since you are using release pipeline, you need to make sure that the source branch is master.

    enter image description here

    And you could get the Source alias.

    The script path: $(System.ArtifactsDirectory)/{Source alias}/TestScenarios.robot