Commit ffa2a980 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch...

Merge branch 'fix/sm/37991-avoid-deactivation-when-pipeline-schedules-execute-a-commit-includes-ci-skip' into 'master'

Avoid deactivation when pipeline schedules execute a branch includes `[ci skip]` comment

Closes #37991

See merge request gitlab-org/gitlab-ce!15405
parents aaf156eb 03aaf90a
...@@ -9,7 +9,7 @@ class PipelineScheduleWorker ...@@ -9,7 +9,7 @@ class PipelineScheduleWorker
pipeline = Ci::CreatePipelineService.new(schedule.project, pipeline = Ci::CreatePipelineService.new(schedule.project,
schedule.owner, schedule.owner,
ref: schedule.ref) ref: schedule.ref)
.execute(:schedule, save_on_errors: false, schedule: schedule) .execute(:schedule, ignore_skip_ci: true, save_on_errors: false, schedule: schedule)
schedule.deactivate! unless pipeline.persisted? schedule.deactivate! unless pipeline.persisted?
rescue => e rescue => e
......
---
title: Avoid deactivation when pipeline schedules execute a branch includes `[ci skip]`
comment
merge_request: 15405
author:
type: fixed
...@@ -22,25 +22,32 @@ describe PipelineScheduleWorker do ...@@ -22,25 +22,32 @@ describe PipelineScheduleWorker do
end end
context 'when there is a scheduled pipeline within next_run_at' do context 'when there is a scheduled pipeline within next_run_at' do
it 'creates a new pipeline' do shared_examples 'successful scheduling' do
expect { subject }.to change { project.pipelines.count }.by(1) it 'creates a new pipeline' do
expect(Ci::Pipeline.last).to be_schedule expect { subject }.to change { project.pipelines.count }.by(1)
expect(Ci::Pipeline.last).to be_schedule
pipeline_schedule.reload
expect(pipeline_schedule.next_run_at).to be > Time.now
expect(pipeline_schedule).to eq(project.pipelines.last.pipeline_schedule)
expect(pipeline_schedule).to be_active
end
end end
it 'updates the next_run_at field' do it_behaves_like 'successful scheduling'
subject
expect(pipeline_schedule.reload.next_run_at).to be > Time.now context 'when the latest commit contains [ci skip]' do
end before do
allow_any_instance_of(Ci::Pipeline)
it 'sets the schedule on the pipeline' do .to receive(:git_commit_message)
subject .and_return('some commit [ci skip]')
end
expect(project.pipelines.last.pipeline_schedule).to eq(pipeline_schedule) it_behaves_like 'successful scheduling'
end end
end end
context 'inactive schedule' do context 'when the schedule is deactivated' do
before do before do
pipeline_schedule.deactivate! pipeline_schedule.deactivate!
end end
......
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