Home > Mobile >  Migrating azure-pipelines.yaml to separate repo, but running on code of other repo
Migrating azure-pipelines.yaml to separate repo, but running on code of other repo

Time:10-31

Ultimately, I'm trying to do this:

  • Move azure-pipelines.yaml and associated templates out of the code repository (code-repo).
  • Move them into a separate dedicated repository (pipeline-repo).
  • Have the pipeline look at the config for the pipeline in pipeline-repo, but run the pipeline on the code in the code-repo.

I'm referring the following documentation:

  • enter image description here

    My actual PR pipeline would look something like this:

    trigger: none
    
    resources:
      repositories:
      - repository: code-repo
        type: git
        name: code-repo
    
    variables:
    - template: templates/variables.yaml
    
    pool:
      vmIMage: $(vmImageName)
    
    stages:
    - template: templates/build/buildStage.yaml
    ...
    

    Testing that, it confirms that it isn't running on the code-repo PR, but the pipeline-repo so everything fails.

    So it is unclear to me what I need to do from here to get the pipeline to run on the PR code from code-repo.

    Suggestions?

    CodePudding user response:

    Ok, I think I have it sorted out, at least some of my stages are now succeeding.

    I came across this documentation which informed me of checkout.

    So in addition to doing something like:

    resources:
      repositories:
      - repository: code-repo
        type: git
        name: code-repo
    

    Then you need to add a step called checkout like the following:

    # Triggers when PR is created due to branch policies
    trigger: none
    
    resources:
      repositories:
      - repository: code-repo
        type: git
        name: code-repo
    
    pool:
      vmImage: 'ubuntu-latest'
    
    stages:
    - stage: Testing
      displayName: Test stage
      jobs:
      - job: ParallelA
        steps:
        - checkout: code-repo
        - task: task1
        - task: task2
    

    The checkout should set the context for the subsequent steps.

  • Related