I am trying to use Azure pipeline templates to organize my build. I am using multiple repositories for this:
- BuildTemplates
- MySoftwareProject1
- MySoftwareProject2
- MySoftwareProjectN
The BuildTemplates repo contains all templates and I want to use these from my other repos. I am trying to make sure that when the BuildTemplates repo is changed - not a single pipeline gets triggered to run (these are templates and should not run) - more on this later. The folder structure is like so:
I've also added these templates as pipeline to Azure (which is a bit unconventional):
This is great because now I can use the editor for azure pipelines. If I edit the .yml directly from the repo, or do that locally, I don't get the nice tooling:
This works but now every time the BuildTemplates repository is updated, it will run these template pipelines - which will fail.
I've tried to set trigger: none
which works when importing jobs, but not when importing steps.
Here are all the yaml files that make up this build:
trigger:
- master
pool:
vmImage: 'windows-latest'
resources:
repositories:
- repository: BuildTemplates
type: git
name: HMI/BuildTemplates
extends:
template: NuGet/Jobs/NuGet.Build.yml@BuildTemplates
# Don't run templates NOTE: this works!
trigger: none
parameters:
- name: packagesToPack
type: string
default: '**/*.nuspec'
jobs:
- job: package
steps:
- template: ../Steps/NuGet.Build.yml
parameters:
packagesToPack: ${{ parameters.packagesToPack }}
# Don't run templates NOTE: this does not work!
# trigger: none
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
command: 'pack'
packagesToPack: ${{ parameters.packagesToPack }}
versioningScheme: 'byPrereleaseNumber'
majorVersion: '7'
minorVersion: '1'
patchVersion: '0'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'Files'
publishLocation: 'Container'
When I uncomment #trigger: none
from the /steps/NuGet.Build.yml
file the following happens when trying to run a build (with the first mentioned yaml file)
/NuGet/Steps/NuGet.Build.yml@BuildTemplates (Line: 3, Col: 1): Unexpected value 'trigger'
My question therefore is: How can I stop templates from running automatically when I have them defined as a pipeline so that I can use the pipeline editor?
Can I disable the pipeline from running somewhere? Can I conditionally add 'trigger: none'?
I was also thinking of create a trigger-none.yml
file with the contents being only trigger: none
and use extend to optionally include it or something - but I don't believe that would work.
Is there perhaps another way I can edit the templates with tooling support - is there for example a vscode extension or something?
Resources->YAML Templatel-> banch version
cause i don't quite follow. – sommmen