We use shared YAML templates extensively in our YAML builds. Something like this:
trigger: none
resources:
repositories:
- repository: templates
type: git
name: DFDevOps\cicd-templates
ref: refs/tags/stable-1
# http://tdc1tfsapp01:8080/tfs/DefaultCollection/DFDevOps/_git/cicd-templates
name: $(BuildVersionPrefix).$(DayOfYear)$(Date:HH)
jobs:
- job: Build
pool:
demands: DotNetFramework
workspace:
clean: outputs
timeoutInMinutes: 180
steps:
- checkout: self # self represents the repo where the initial Pipelines YAML file was found
clean: true
lfs: true
- template: ci/ci-build.yml@templates
parameters:
releaseBranch: $(ReleaseBranch)
However, the shared YAML templates often need to execute Powershell code. So far we either embed it or put it in a PS module, which the templates load.
I hate both approaches. I hate embedding because:
- No intellisens
- No unit testing
- No proper error reporting on pipeline failures
I hate putting in a module, because it is detached from the origin and requires a lot of overhead.
My question - is it possible to have the PS code in dedicated ps1 files in the same repo as the YAML templates and yet have them available at run time?