Skip to content

Draft: Import/export support for callback jobs

What does this MR do and why?

Adds the Importable concern and supporting configuration to the new model added in !134938 (closed).

Note that there is currently no way for instances of these models to be created, as they will be configured using a new CI keyword that is to be added in a subsequent issue (#415737). There should therefore be no impact to existing imports/exports.

How to set up and validate locally

  1. Go to Admin -> Settings -> General -> Import & Export settings, enable "GitLab export" as an import source, and enable project exports.
  2. Create a project, and add a minimal .gitlab-ci.yml such as:
    test:
      stage: test
      when: manual # So the job won't get picked by a runner
      script:
        - echo 'test'
  3. In a Rails console, update the job's type in the pipeline that was created:
    job = Ci::Build.find <job-id>
    job.update! type: 'Ci::CallbackJob', status: :waiting_for_callback
    job.ci_stage.update! status: :waiting_for_callback
    job.pipeline.update! status: :waiting_for_callback
  4. Go to Settings -> General and click "Export project"
  5. Refresh after a second or two, and click "Download export"
  6. Create a new project, selecting "Import", and then "GitLab export"
  7. Select the export file you downloaded previously
  8. When the import is finished, view the only pipeline for the project and observe the imported callback job (it will be in the cancelled state because all non-finished jobs are cancelled on import)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #415736

Edited by Tiger Watson

Merge request reports