You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为特定Docker镜像加标签解决Azure DevOps Terraform Plan镜像找不到问题

问题:Azure DevOps依赖流水线Terraform拉取Docker镜像出现404错误

使用MainPipeline触发下游DependantPipeline时,DependantPipeline的Terraform Plan步骤拉取Docker镜像报错,提示找不到对应标签的镜像。手动添加该标签后,流水线可正常执行。


相关配置文件

deploying.yml

parameters:
  - name: pipelineOptions
    type: object
  - name: environment
    type: string
  - name: env
    type: string
  - name: region
    type: string
    default: $(region)

jobs:
  - template: cicd/deployment.yml@Pipelines
    parameters:
      pipelineOptions: ${{parameters.pipelineOptions}}
      environment: ${{parameters.environment}}

  - template: ./terraform/deploy.yml
    parameters:
      pipelineOptions: ${{parameters.pipelineOptions}}
      environment: ${{parameters.environment}}
      env: ${{parameters.env}}
      region: ${{parameters.region}}

/cicd/terraform/deploy.yml

parameters:
  - name: pipelineOptions
    type: object
  - name: environment
    type: string
  - name: region
    type: string
    default: $(region)
    [...]

jobs:
  - deployment: terraform_plan
      displayName: "Teraform Plan"
    environment: ${{parameters.environment}}
    workspace:
      clean: all
    strategy:
      runOnce:
        deploy:
          steps:
            [...]
            - task: TerraformCLI@0
              displayName: 'Terraform Plan'
              name: plan
              inputs:
                command: plan
                publishPlanResults: 'Terraform-Plan-${{parameters.env}}-$(System.StageAttempt)'
                workingDirectory: '$(Pipeline.Workspace)/${{parameters.artifactName}}/terraform'
                commandOptions: '-out=$(Build.ArtifactStagingDirectory)/terraform/terraform.tfplan -detailed-exitcode'

错误输出

Terraform Plan步骤日志:

资源流水线的pipelineID为379701,runID为379701,runName为379701

Terraform Plan任务报错:

从注册表获取379702时出错:收到错误响应:404 Not Found


已做修改

修改了deploy.yml中的TerraformCLI任务:

- task: TerraformCLI@0
              displayName: 'Terraform Plan'
              name: plan
              inputs:
                command: plan
                publishPlanResults: 'Terraform-Plan-${{parameters.env}}-$(System.StageAttempt)'
                workingDirectory: '$(Pipeline.Workspace)/${{parameters.artifactName}}/terraform'
                commandOptions: '-out=$(Build.ArtifactStagingDirectory)/terraform/terraform.tfplan -compact-warnings -detailed-exitcode -input=false -var-file=./config/$(projectId).tfvars -var="source_pipeline_runid=$(resources.pipeline.SourcePipeline.runID)"'

同时在variables.tf中新增变量并在其他.tf文件引用:

variable "source_pipeline_runid" {
  description = "runID"
  type        = string
}

内容的提问来源于stack exchange,提问作者Kreg

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 19:23:13