Cypress Integration with DevOps

若如初见. 提交于 2021-02-11 14:16:21

问题


What I want to achieve:

I have a repository on Azure DevOps which hosts my web application. I wrote a test suite for UI Automation using Cypress. I created a separate repository for my test cases to check if they are working properly or not. I created a pipeline which has the following content:

trigger:
- manual-tests
pool:
  vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'

- script: |
    npm install
  displayName: 'npm install'

- task: Npm@1
  inputs:
    command: 'custom'
    customCommand: 'run test'
  continueOnError: true

- task: PublishTestResults@2
  inputs:
    testResultsFormat: 'JUnit'
    testResultsFiles: '**/test-output-*.xml'
    testRunTitle: 'My Test Cases'

I have a trigger set to a branch of the repository in which my UI Automation code is stored. What I want is, to trigger my automation script, when there is a push on some branch of the web application repository. Is there a way of doing this? Can we store our test case files in the application repository and give the path of the test script?


回答1:


It seems that the UI Automation Repo and Web Application Repo are two separate repos.

To trigger my automation script, when there is a push on some branch of the web application repository. Is there a way of doing this?

The function: "trigger a pipeline from a different repo" is not available now.

This feature is still under development. Multi-repository support for YAML pipelines will be available soon for azure devops service.

Please check the function:"Multi-repository support for YAML pipelines" in Azure DevOps Feature Timeline 2020 Q2. This feature will roll out to everyone by the end of July 2020.

Workaround:

You could try to use the Pipeline triggers.

Here are the steps:

Step1: Create a pipeline with web application repository, then you could set the trigger branch.

Step2: Add the Pipeline trigger in the Yaml file (UI Automation Repo).

For example:

resources:
  pipelines:
  - pipeline: Name   
    source: Pipeline name
    trigger: 
      branches:
      - releases/*
      - master

When you make changes in web application repository, the pipeline with the web application will be triggered.

After running the pipeline , the pipeline with UI Automation repo will be triggered.

Can we store our test case files in the application repository and give the path of the test script?

Of cource. You can do it.

If you want to use the test file in the pipeline (UI Automation repo), you could add the repo resouces in the pipeline.

For example:

resources:
  repositories:
  - repository: MyAzureReposGitRepository
    type: git
    name: MyProject/WebapplicationRepo
...
steps:
- checkout: MyAzureReposGitRepository

Note: the repo will be check out to the Agent Source Folder.

Hope this helps.



来源:https://stackoverflow.com/questions/62690710/cypress-integration-with-devops

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!