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

如何让CircleCI触发流水线弹窗预填配置文件默认参数?

CircleCI 流水线参数预填显示解决方案

要让配置中的默认参数自动出现在CircleCI触发流水线的弹窗中,需要将参数定义为全局流水线参数,而非作业内部参数。具体操作如下:

  1. 调整配置文件结构
    在.circleci/config.yml的最顶层(与version、workflows同级)添加parameters块,把你的参数放在这里:

    version: 2.1
    
    parameters:
      region:
        type: string
        default: nonprod
      browser:
        type: string
        default: chrome
      tags:
        type: string
        default: priority1
      endCustomer:
        type: string
        default: excelBCustomers
    
    workflows:
      # 示例工作流,根据实际需求修改
      test-workflow:
        jobs:
          - test-job:
              region: << pipeline.parameters.region >>
              browser: << pipeline.parameters.browser >>
              tags: << pipeline.parameters.tags >>
              endCustomer: << pipeline.parameters.endCustomer >>
    
    jobs:
      test-job:
        parameters:
          region:
            type: string
          browser:
            type: string
          tags:
            type: string
          endCustomer:
            type: string
        executor:
          name: docker
          image: cimg/node:20.10.0
        steps:
          - checkout
          # 示例:在作业中使用参数
          - run: echo "当前Region: << parameters.region >>"
    
  2. 验证效果
    将修改后的配置推送到代码仓库,再次点击CircleCI的「触发流水线」按钮,弹窗中的「Pipeline Parameters(可选)」区域会自动显示所有预定义参数,且默认值已填充完成,无需手动输入。

  3. 关键注意事项

    • 必须确保参数是顶层parameters,作业内部的参数不会在流水线触发弹窗中显示。
    • 严格遵循YAML语法规范,缩进保持一致(通常用2个空格),避免语法错误导致配置不生效。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.13 07:05:50