让我们考虑一下,我有一个 sonar.yml
模板,其中包含一个名为 build_tasks
的类型为 stepList
的参数,如下所示:
#sonar.yml
parameters:
- name: build_tasks
type: stepList
default: []
steps:
- task: SonarQubePrepare@4
displayName: 'Prepare Sonar analysis'
inputs:
SonarQube: 'SonarQube'
scannerMode: 'MSBuild'
projectKey: 'Bacon.Api'
- ${{ parameters.build_tasks }}
- task: SonarQubeAnalyze@4
displayName: 'Run Sonar analysis'
- task: SonarQubePublish@4
displayName: 'Publish Sonar analysis'
inputs:
pollingTimeoutSec: '300'
另一个名为 build.yml
的模板:
#build.yml
steps:
- task: DotNetCoreCLI@2
displayName: 'Restore'
inputs:
command: 'restore'
projects: '**/*.sln'
- task: DotNetCoreCLI@2
displayName: 'Build'
inputs:
command: 'build'
arguments: '--no-restore'
projects: '**/*.sln'
是否可以以某种方式将 build.yml
作为 build_tasks
参数传递给 sonar.yml
?
大致如下:
#base.yml
jobs:
- job: sonar_analysis
displayName: SonarQube
pool:
vmImage: 'ubuntu-latest'
steps:
- template: sonar.yml
parameters:
- build_tasks: build.yml
答案 0 :(得分:1)
事实证明确实有可能。
我只是在参数上使用了错误的语法,我已经更正了,现在一切都按预期工作了。
#base.yml
- job: sonar_analysis
displayName: SonarQube
pool:
vmImage: 'ubuntu-latest'
steps:
- template: sonar.yml
parameters:
build_tasks:
- template: build.yml