【问题标题】:Where can we specify Github repository path in Tasks in Azure Devops?在 Azure Devops 的 Tasks 中,我们可以在哪里指定 Github 存储库路径?
【发布时间】:2020-09-02 18:25:53
【问题描述】:

我创建了一个任务组来在 Azure DevOps 中运行机器人框架脚本。我已将以下任务添加到任务组:

  1. 使用 Python 版本
  2. 安装机器人框架的 Python 脚本
  3. 运行机器人框架脚本的 Python 脚本任务
  4. 发布测试结果

在任务Python script task to run robot framework script中,我有以下内联脚本:

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

TestScenarios.robot 存在于我的 GitHub 存储库中。所以我的问题是我在哪里可以指定需要从我的 GitHub 存储库中获取 TestScenarios.robot。 我无法弄清楚如何在任务中做到这一点。 我知道在设置管道时,我们有一个配置选项,我们可以在其中指定 GitHub 存储库。但我想知道我们如何为任务提供 GitHub 存储库详细信息? 然后我想在我的阶段发布中使用这个任务组,这样每当我们部署一个发布时,任务组就会被触发来运行自动化脚本。 如果您需要更多详细信息,请告诉我。

【问题讨论】:

    标签: azure-devops azure-pipelines azure-task-groups


    【解决方案1】:

    对于构建管道:

    构建开始时,源代码库将下载到$(Build.SourcesDirectory)

    因此您可以将 repo 路径指定为$(Build.SourcesDirectory)/Scriptfolder/xx.robot

    这是我的例子:

    xx.robot 在 ScriptFolder 中。

    机器人框架脚本:

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

    对于发布管道

    在Release中,源将下载到$(System.ArtifactsDirectory)/{Source alias }

    注意Source alias 位于Release definition -> Artifacts

    这是我的脚本示例:

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

    这里是关于 Build VariablesRelease Variables 的文档。

    更新:

    由于您使用的是发布管道,因此您需要确保源分支是 master。

    你可以得到源别名。

    脚本路径:$(System.ArtifactsDirectory)/{Source alias}/TestScenarios.robot

    【讨论】:

    • 感谢您的回答。我会试试这个。
    • @Komz。如果答案能给你一些帮助,请随时告诉我。如果您还有任何问题,我仍然会在这里为您提供帮助。
    • @ Kevin Lu-MSFT 抱歉,我无法解决,仍然卡住。我的 github ABC/xyz -- master 分支中有我的 TestScenarios.robot
    • @Komz。 ABC 和 xyz 是文件夹名称?或 ABC 是回购名称 xyz 是文件夹名称?如果是后者,你只需要指定路径:$(build.sourcesdirectory)/xyz/xxx.robot。您是在构建还是发布管道中?
    • @ Kevin Lu-MSFT 我正在发布管道中。 xyz 是仓库名称
    猜你喜欢
    • 2019-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-17
    • 2021-03-05
    相关资源
    最近更新 更多