I prepared a template to re use it across all of my pipelines. It looks like this:
stages:
- stage: Defender
displayName: Defender
pool:
vmImage: windows-latest
jobs:
- job: Scan
displayName: Scan
steps:
- task: MicrosoftSecurityDevOps@1
displayName: Microsoft Security DevOps
inputs:
config: ../configs/config.gdnconfig
Folder structure looks like this:
- PROJ/ado-templates (root folder of template's repo)
- templates
- template.yml
- configs
- config.gdconfig
Then, in pipeline i use this template as present:
resources:
repositories:
- repository: templates
type: git
name: PROJ/ado-templates
stages:
- template: templates/microsoft-security.yml@templates
But during scan i got an error:
##[error]ConfigurationPathNotFoundException: A configuration file could not be found for: ../configs/config.gdnconfig. This is often due to attempting to use a tool on a platform where it is not yet supported. ##[error]MSDO CLI exited with an error exit code: 1
When i run ls -al $(Build.SourcesDirectory)
script in this pipeline through template, i do not see that template files there. Only files from the repo where template is used
The question is, how to read config file that is saved in the same repo as template used in this pipeline?
You are only reference the yaml but not checkout the repo where config.gdnconfig
exists.
Add checkout step in template.yaml:
stages:
- stage: Defender
displayName: Defender
pool:
vmImage: windows-latest
jobs:
- job: Scan
displayName: Scan
steps:
- checkout: templates
- script: |
cat configs/config.gdnconfig # check the content
- task: MicrosoftSecurityDevOps@1
displayName: Microsoft Security DevOps
inputs:
config: configs/config.gdnconfig # remove .. at the begining
In addition, make sure the config file name is correct.