Home > Enterprise >  How do I set up PR validations in Azure DevOps/GitHub?
How do I set up PR validations in Azure DevOps/GitHub?

Time:09-27

We are migrating from Azure DevOps to GitHub and we have Build Validations set up where if you make a change in a specific folder, the respective CI pipeline will run when a PR is created.

I am trying to make use of the PR triggers in my YAML file, however when I open a PR it doesn't seem to work.

My pipeline is:

trigger: none

pr:
  branches:
    include:
      - develop
      - release/*
      - ProductionSupport/*
  paths:
    include:
      - cicd/pipelines/common/pre-commit-ci.yaml
      - src
      - cicd

pool:
  vmImage: ubuntu-latest

variables:
  PRE_COMMIT_HOME: $(Pipeline.Workspace)/pre-commit-cache

steps:
  - bash: echo "##vso[task.setvariable variable=PY]`python -V`"
    displayName: Get python version
  - task: Cache@2
    inputs:
      key: pre-commit | .pre-commit-config.yaml | "$(PY)"
      path: $(PRE_COMMIT_HOME)

  - bash: |
      pip install --quiet pre-commit
      pre-commit run
    displayName: 'Run pre-commit'

As a test to make sure my branches/paths were correct I updated the triggers section to:

trigger:
  branches:
    include:
      - develop
      - release/*
      - ProductionSupport/*
  paths:
    include:
      - cicd/pipelines/common/pre-commit-ci.yaml
      - src
      - cicd

Then when I made a change in one of the files in these folders, the pipeline was successfully triggered. Am I specifying my PR validation incorrectly?

CodePudding user response:

Your yml definition seems correct.

Since you mentioned the CI trigger work fine and you mentioned We are migrating from Azure DevOps to GitHub.

This brings me a idea that a situation that exactly reproduces what you're experiencing and you might not expect:

PR Trigger Override

For example, if your pipeline is the same one as before(Just change the pipeline source), and you didn't delete the previous build validation(Or previous pipeline name is same as the current one), then the pr part in your github yml file will be override, only the build validation on DevOps side will work.

I suggest you investigate whether you have some build validation settings to the pipeline(If your project structure is complex, this maybe difficult to find) or you can simply create a totally new pipeline with the new YAML file.

  • Related