Commit bce723f0 authored by lauraMon's avatar lauraMon

Adds validation to job length

parent 7f9a6419
---
name: ci_validate_job_length
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/73599
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/344665
milestone: '14.5'
type: development
group: group::pipeline authoring
default_enabled: true
......@@ -82,7 +82,7 @@ For example:
![Pipeline mini graph sorting](img/pipelines_mini_graph_sorting.png)
## Unavailable names for jobs
## Job name limitations
You can't use these keywords as job names:
......@@ -96,6 +96,10 @@ You can't use these keywords as job names:
- `cache`
- `include`
Job names must be 255 characters or less. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/342800)
in GitLab 14.5, [with a feature flag](../../administration/feature_flags.md) named `ci_validate_job_length`.
Enabled by default. To disable it, ask an administrator to [disable the feature flag](../../administration/feature_flags.md).
## Group jobs in a pipeline
If you have many similar jobs, your [pipeline graph](../pipelines/index.md#visualize-pipelines) becomes long and hard
......
......@@ -23,6 +23,7 @@ module Gitlab
validates :config, presence: true
validates :name, presence: true
validates :name, type: Symbol
validates :name, length: { maximum: 255 }, if: -> { ::Feature.enabled?(:ci_validate_job_length, default_enabled: :yaml) }
validates :config, disallowed_keys: {
in: %i[only except when start_in],
......
......@@ -33,6 +33,14 @@ RSpec.describe Gitlab::Ci::Config::Entry::Processable do
end
end
context 'when job name is more than 255' do
let(:entry) { node_class.new(config, name: ('a' * 256).to_sym) }
it 'shows a validation error' do
expect(entry.errors).to include "job name is too long (maximum is 255 characters)"
end
end
context 'when job name is empty' do
let(:entry) { node_class.new(config, name: ''.to_sym) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment