gitlabgitlab-cigitlab-ci-runnergitlab-ce

GitLab CI: Two independent scheduled jobs


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?


Solution

  • 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