假设我有一个 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
最佳答案
事实证明这确实是可能的。
我只是在参数上使用了错误的语法,我已更正它,现在一切都按预期工作。
#base.yml
- job: sonar_analysis
displayName: SonarQube
pool:
vmImage: 'ubuntu-latest'
steps:
- template: sonar.yml
parameters:
build_tasks:
- template: build.yml
关于azure - 是否可以在 Azure Devops 管道中将模板作为 stepList 参数传递?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65818077/