0
votes

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
Hi @Haris Bin Saif. Feel free to let me know if the answer could give you some help. If I have some misunderstandings about your repos , you could correct me. Then I will test it again and give some help. Thanks.Kevin Lu-MSFT
Hi @KevinLu-MSFT! The answer is very thorough and very well explained. I'll try it out and let you know if I face any more issues or this works fine. Thank you again for the answerHaris
Hey @KevinLu-MSFT thank you for such a detailed answer. I wish Microsoft had a support for multiple repositories in YAML file. That would have made our life a lot easier :D but you brief answer helped me a lot. And the workaround works perfectly fine. Thankyou!Haris
Don’t worry, this feature is coming soon.Kevin Lu-MSFT
Hi @KevinLu-MSFT, So, I ran into another issue here, One of my pipeline is in a separate project. So i used "project: name_of_proj" for it to work. I tested it on my test organization and it was working. But when I implemented it on the real organization, it did not trigger the other pipeline. Is it something because of permissions? Is there a way to debug it?Haris

1 Answers

1
votes

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.