首页 > 解决方案 > 仅使用动态:更改 .gitlab-ci.yml 中的配置

问题描述

鉴于我有这样的存储库结构:

app-1
 \_ conf 
     \_ app.properties
     \_ secrets.properties
 \_ some.properties

app-2
 \_ conf 
     \_ app.properties
     \_ secrets.properties
 \_ some.properties

app-n
...

我想only:changes用来定义是否应根据 Git 推送事件修改的文件创建作业:

app-1:
  script:
    - echo "Do stuff here"
  only:
    changes:
      - app-1/**/*
    refs:
      - master

app-2:
  script:
    - echo "Do stuff here"
  only:
    changes:
      - app-2/**/*
    refs:
      - master

app-n
...

但这很快就会变得不守规矩和重复。有没有办法对此进行模板化?IE:

job:
  script:
    - echo "Do stuff here"
  only:
    changes:
      - $MAYBE_SOME_ENV_VAR_THAT_HAS_PATHS/**/*
    refs:
      - master

标签: gitlabgitlab-ci

解决方案


推荐阅读