考虑以下?'%in%'
脚本:
gilab-ci.yml
我希望能够独立安排这两项工作,但要遵循以下规则:
但是,在当前设置下,我只能触发整个管道,这将依次执行两个作业。
如何安排只触发一项工作的时间表?
答案 0 :(得分:1)
在项目内部的gitlab中转到
CI/CD
-> Schedules
按新的“计划”按钮,根据需要设置时间和间隔来配置任务
现在在最后为每个变量添加一个变量
现在通过在only
部分添加该变量来编辑gitlab.yml
如下所示
https://docs.gitlab.com/ee/ci/variables/#environment-variables-expressions
答案 1 :(得分:1)
要建立@Naor Tedgi的答案,您可以在管道计划中定义一个变量。例如,在build_for_ui_automation的时间表中设置SCHEDULE_TYPE = "build_ui"
,在Independent_job的时间表中设置SCHEDULE_TYPE = "independent"
。然后可以将您的.gitlab-ci.yml
文件修改为:
stages:
- build_for_ui_automation
- independent_job
variables:
LC_ALL: "en_US.UTF-8"
LANG: "en_US.UTF-8"
before_script:
- gem install bundler
- bundle install
build_for_ui_automation:
dependencies: []
stage: build_for_ui_automation
artifacts:
paths:
- fastlane/screenshots
- fastlane/logs
- fastlane/test_output
- fastlane/report.xml
script:
- bundle exec fastlane ui_automation
tags:
- ios
only:
refs:
- schedules
variables:
- $SCHEDULE_TYPE == "build_ui"
allow_failure: false
# This should be added and trigerred independently from "build_for_ui_automation"
independent_job:
dependencies: []
stage: independent_job
artifacts:
paths:
- fastlane/screenshots
- fastlane/logs
- fastlane/test_output
- fastlane/report.xml
script:
- bundle exec fastlane independent_job
tags:
- ios
only:
refs:
- schedules
variables:
- $SCHEDULE_TYPE == "independent"
allow_failure: false
请注意,only
节中的语法更改为仅在计划期间和计划变量匹配时才执行作业。