Consider the following gilab-ci.yml
script:
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:
- schedules
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:
- schedules
allow_failure: false
I'd like to be able to schedule these two jobs independently, but following the rules:
However, with the current setup I can only trigger the whole pipeline, which will go through both jobs in sequence.
How can I have a schedule triggering only a single job?
To run our tests in parallel as part of our GitLab CI/CD pipeline, we need to tell GitLab to start multiple test jobs at the same time. In each of the test jobs we then run a different subset of our test suite. For our example project we start by adding separate build , test and deploy jobs.
No, you can't have multiple gitlab-ci files per repository.
GitLab provides a method to make clones of a job and run them in parallel for faster execution using the parallel: keyword. While parallel jobs may not help in reducing the consumption of CI minutes, they definitely help increase work productivity.
One way to allow more jobs to run simultaneously is to simply register more runners. Each installation of GitLab Runner can register multiple distinct runner instances. They operate independently of each other and don't all need to refer to the same coordinating server.
To build off @Naor Tedgi's answer, you can define a variable in your pipeline schedules. For example, set SCHEDULE_TYPE = "build_ui"
in the schedule for build_for_ui_automation and SCHEDULE_TYPE = "independent"
in the schedule for independent_job. Then your .gitlab-ci.yml
file could be modified as:
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
where note the syntax change in the only
sections to execute the jobs only during schedules and when the schedule variable is matching.
in gitlab inside your project go to
CI/CD
-> Schedules
press new Schedule button config the tasks as you want set the time and interval
now at the end add a variable for each one of them
now edit your gitlab.yml by adding that variable at the only
section
as shown here below
https://docs.gitlab.com/ee/ci/variables/#environment-variables-expressions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With