Housekeeper: Add support for `ci.skip`
What does this MR do and why?
In certain scenarios, when creating a Merge Request (MR) through a Keep, it's beneficial to bypass the pipeline creation upon committing changes. This is handy in cases where a keep can commit files in an automated fashion, yet some files might require manual updates from the user, such as specs. In such cases, before the manual updates to specs are made, the pipeline is gonna fail anyway, and it is better to skip it rather than needlessly running the pipeline.
By providing an option within the keep to skip the pipeline during commit creation using GitLab's push options, specifically -o ci.skip
, we can prevent the pipeline from running needlessly, if need be. This option is turned off by default, and needs to be turned on from within a keep.
Usage
# keeps/pretty_useless_keep.rb
module Keeps
class PrettyUselessKeep < ::Gitlab::Housekeeper::Keep
def each_change
(1..3).each do |i|
file_name = "new_file#{i}.txt"
`touch #{file_name}`
change = ::Gitlab::Housekeeper::Change.new
change.identifiers = [self.class.name.demodulize, "new_file#{i}"]
change.title = "Make new file #{file_name}"
change.description = <<~MARKDOWN
## New files
This MR makes a new file #{file_name}
MARKDOWN
change.labels = %w(type::feature)
change.changed_files = [file_name]
change.push_options.ci_skip = true # <==== PUSH OPTIONS CAN BE SPECIFIED THIS WAY
yield(change)
end
end
end
end
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.