相关疑难解决方法(0)

在 azure 管道作业中使用 for 循环

我将使用 for 循环扫描文件夹中的文件(value-f1.yaml、values-f2.yaml...),每次使用文件名作为变量并在 Azure 管道作业中运行该作业根据该值文件部署 helmchart。该文件夹位于 GitHub 存储库中。所以我在想这样的事情:

管道.yaml

 stages:
  - stage: Deploy
    variables:
      azureResourceGroup: ''
      kubernetesCluster: ''
      subdomain: ''
    jobs:
    ${{ each filename in /myfolder/*.yaml}}:
       valueFile: $filename 
       - template: Templates/deploy-helmchart.yaml@pipelinetemplates    
Run Code Online (Sandbox Code Playgroud)

部署-helmchart.yaml

 jobs:
    - job: Deploy
      pool:
        vmImage: 'ubuntu-latest'
      steps:
      - task: HelmInstaller@1
        displayName: 'Installing Helm'
        inputs:
          helmVersionToInstall: '2.15.1'
        condition: and(succeeded(), startsWith(variables['build.sourceBranch'], 'refs/tags/v'))  

      - task: HelmDeploy@0
        displayName: 'Initializing Helm'
        inputs:
          connectionType: 'Azure Resource Manager'
          azureSubscription: $(azureSubscription)
          azureResourceGroup: $(azureResourceGroup)
          kubernetesCluster: $(kubernetesCluster)
          command: 'init'
        condition: and(succeeded(), startsWith(variables['build.sourceBranch'], 'refs/tags/v'))  

      - task: PowerShell@2
        displayName: …
Run Code Online (Sandbox Code Playgroud)

for-loop azure-devops azure-pipelines

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

azure-devops ×1

azure-pipelines ×1

for-loop ×1