0

I am building a pipeline using a template (and nextly will be more pipelines using the same template). My problem is when I change something in the template the pipeline is executed, that means when there be more pipelines using the template, all will be executed.

Is there anyway to indicate that when template changes I don't need to execute pipeline automatically?

this is my template:

parameters:
- name: repoName # name of the parameter; required
  type: string # data type of the parameter; required
  default: ''


jobs:
- job: BuildImage
  displayName: Build

  pool:
    name: Azure Pipelines
    demands: java  
    vmImage: ubuntu-20.04
    
  steps:
  - checkout: ${{ parameters.repoName }}
    clean: true
    fetchDepth: 1

  - task: Gradle@2
    displayName: 'gradlew clean'
    inputs:
      workingDirectory: ./
      tasks: clean
      publishJUnitResults: false
      jdkVersionOption: 1.11

  - task: Gradle@2
    displayName: 'gradlew build'
    inputs:
      options: '-x test'
      publishJUnitResults: false
      jdkVersionOption: 1.11

  ##Fix Jacoco
  - task: Gradle@2
    displayName: 'gradlew test'
    inputs:
      tasks: test
      publishJUnitResults: false
      codeCoverageToolOption: JaCoCo
      jdkVersionOption: 1.11

  ## Add Sonar 

and here the template is using it:

resources:
  repositories: 
  - repository: repository
    type: git
    name: CORE_tpaas-utilities
    ref: 'refs/heads/development'

extends:
  template: ../templates/ci.yml
  parameters: 
    repoName: repository
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

1 Answers1

1

You can use the path filter for your pipeline trigger. For example add below to your pipeline yaml file.

resources:
....

trigger: 
  paths:
    exclude:
    - path/to/template.yml

extends:
....

After you specify above path filter to exclude the template yaml file for the pipeline trigger. The pipeline will not be executed when changes are made to the template file.

See here for more information.

Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43