diff --git a/app/models/ci/pipeline_schedule_variable.rb b/app/models/ci/pipeline_schedule_variable.rb index ee5b8733fac..6c9c8d990f9 100644 --- a/app/models/ci/pipeline_schedule_variable.rb +++ b/app/models/ci/pipeline_schedule_variable.rb @@ -5,6 +5,6 @@ module Ci belongs_to :pipeline_schedule - validates :key, uniqueness: { scope: :pipeline_schedule_id } + validates :key, uniqueness: { scope: :pipeline_schedule_id }, presence: { unless: :importing? } end end diff --git a/doc/ci/variables/README.md b/doc/ci/variables/README.md index 664ef4f66a8..72f4c24fb94 100644 --- a/doc/ci/variables/README.md +++ b/doc/ci/variables/README.md @@ -9,7 +9,7 @@ and a list of **user-defined variables**. The variables can be overwritten and they take precedence over each other in this order: -1. [Trigger variables][triggers] or [scheduled pipeline variables](../../user/project/pipelines/schedules#making-use-of-scheduled-pipeline-variables) (take precedence over all) +1. [Trigger variables][triggers] or [scheduled pipeline variables](../../user/project/pipelines/schedules.md#making-use-of-scheduled-pipeline-variables) (take precedence over all) 1. [Secret variables](#secret-variables) or [protected secret variables](#protected-secret-variables) 1. YAML-defined [job-level variables](../yaml/README.md#job-variables) 1. YAML-defined [global variables](../yaml/README.md#variables) diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml index 1860352c96d..2d443aa731f 100644 --- a/lib/gitlab/import_export/import_export.yml +++ b/lib/gitlab/import_export/import_export.yml @@ -42,7 +42,8 @@ project_tree: - :stages - :statuses - :triggers - - :pipeline_schedules + - pipeline_schedules: + - :variables - :services - :hooks - protected_branches: diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml index 0b2e2b335c4..40ae0a1846b 100644 --- a/spec/lib/gitlab/import_export/all_models.yml +++ b/spec/lib/gitlab/import_export/all_models.yml @@ -130,9 +130,9 @@ pipeline_schedules: - owner - pipelines - last_pipeline -- variables pipeline_schedule: - pipelines +- pipeline_schedule_variables pipeline_schedule_variables: - pipeline_schedule deploy_keys: diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 8750cbcb13c..a4f29ce462f 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1371,8 +1371,10 @@ describe Ci::Build, :models do context 'when a job was triggered by a pipeline schedule' do let(:pipeline_schedule) { create(:ci_pipeline_schedule, project: project) } + let!(:pipeline_schedule_variable) do - create(:ci_pipeline_schedule_variable, key: 'SCHEDULE_VARIABLE_KEY', + create(:ci_pipeline_schedule_variable, + key: 'SCHEDULE_VARIABLE_KEY', pipeline_schedule: pipeline_schedule) end