azure - 是否可以在 Azure Devops 管道中将模板作为 stepList 参数传递?

标签 azure azure-devops azure-pipelines

假设我有一个 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/

相关文章:

git - 如何从 Visual Studio 2019 将项目保存到 Azure DevOps?

azure - 配置 Azure Build Pipeline 以运行 .net core 与数据库的自动化集成测试

azure - 在从模板部署的突触管道中分配sparkpoolname时出现问题

azure - 在 Azure DevOps 中,如何为工作项的字段定义默认模板?

github - "Resource not accessible by integration"尝试创建触发器时

sonarqube - 使用 SonarQube 5.2 构建 Breaker 插件

powershell - 如何在 Azure Devops 的任务中运行带参数的 exe?

c# - Azure 更新计划作业 API - 格式错误的作业对象

Azure Rest API 附加现有托管磁盘

azure - Visual Studio Express 2013 中缺少 Azure 移动服务支持