Skynet
Skynet

Reputation: 578

Gitlab CI: manually run single tasks

I'm trying to migrate some old Jenkins stuff to Gitlab CI/CD. I got the CI/CD part sorted out, that works fine - but I have a couple of "odd jobs" that do stuff like "mirror the production database to the staging environment", "mirror production user uploaded assets to staging" and the likes.

How do I express this in Gitlab CI syntax? when:manual jobs don't (really) cut it as the "odd jobs" are totally independent of any pipelines and are needed maybe once a half year tops?

Upvotes: 0

Views: 1155

Answers (2)

Sergio Tanaka
Sergio Tanaka

Reputation: 1435

  1. create a separate repo and put all of your odd jobs there, after this, for each one, create a template file to be used on demand. Check the docs https://docs.gitlab.com/ee/ci/yaml/#include

  2. In your pipeline use only/except filters to load these templates https://docs.gitlab.com/ee/ci/yaml/#onlyexcept-advanced

You will be able to handle the behaviour of your pipeline for example

If commit message contains [mirror-db] load the template mirror-db.yml from odd-jobs repository

include:
  - project: 'my-group/odd-jobs'
    file: '/templates/.db-mirror.yml'

your .db-mirror.yml file

db-mirror:
  stage: odd-job
  script: 
    - echo something
  only:
    refs:
      - master
      - schedules
    variables:
      - $CI_COMMIT_MESSAGE =~ /[db-mirror]/

Upvotes: 1

Aleksey Tsalolikhin
Aleksey Tsalolikhin

Reputation: 1668

These "odd jobs" are not part of your CI pipeline, as you mentioned. Why not put them in their own repo?

Upvotes: 0

Related Questions