0

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.

riQQ
  • 9,878
  • 7
  • 49
  • 66
Komz
  • 5
  • 3

1 Answers1

1

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

Kevin Lu-MSFT
  • 20,786
  • 3
  • 19
  • 28
  • Thanks for answering. I will try this. – Komz Sep 03 '20 at 04:31
  • @Komz. Feel free to let me know if the answer could give you some help. If you still have any questions, I will still be here to help you. – Kevin Lu-MSFT Sep 03 '20 at 05:26
  • @ Kevin Lu-MSFT Sorry, But I am unable to sor it out, still stuck. I have my TestScenarios.robot in my github ABC/xyz -- master branch – Komz Sep 03 '20 at 08:30
  • @Komz. ABC and xyz are folder name? OR ABC is Repo name xyz is folder name? If the latter, you just need to specify the path: `$(build.sourcesdirectory)/xyz/xxx.robot`. Are you in build or release pipeline? – Kevin Lu-MSFT Sep 03 '20 at 08:35
  • On the other hand, Can you share your current configuration path? Thanks. – Kevin Lu-MSFT Sep 03 '20 at 08:36
  • @ Kevin Lu-MSFT .Sorry, But I am unable to sort it out. I have TestScenarios.robot in my github ABC/xyz -- master branch.it is my private repo.when I had created a new pipeline,during configure part , I had to provide credentials to connect to this Github. And It is not the place where Release source will be downloaded. Basically I had created a yaml pipeline to run automation scripts. But now we want test cases to run automatically when Release is deployed. Using triggers I want not able to do that.So he asked me to create task group having all tasks and steps thats present in my yml pipeline – Komz Sep 03 '20 at 08:56
  • 1
    @ Kevin Lu-MSFT I am in release pipeline. xyz is repo name – Komz Sep 03 '20 at 08:57
  • @Komz . Thanks for your information. I probably understand your configuration. Please check the update. You could try the script: `robot --pythonpath . -x outputxunit.xml $(System.ArtifactsDirectory)/{Source alias}/TestScenarios.robot` – Kevin Lu-MSFT Sep 03 '20 at 09:05