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
This commit is contained in:
Kamil Trzciński 2017-11-23 10:39:52 +00:00
commit ffa2a98034
3 changed files with 26 additions and 13 deletions

View file

@ -9,7 +9,7 @@ class PipelineScheduleWorker
pipeline = Ci::CreatePipelineService.new(schedule.project,
schedule.owner,
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?
rescue => e

View file

@ -0,0 +1,6 @@
---
title: Avoid deactivation when pipeline schedules execute a branch includes `[ci skip]`
comment
merge_request: 15405
author:
type: fixed

View file

@ -22,25 +22,32 @@ describe PipelineScheduleWorker do
end
context 'when there is a scheduled pipeline within next_run_at' do
it 'creates a new pipeline' do
expect { subject }.to change { project.pipelines.count }.by(1)
expect(Ci::Pipeline.last).to be_schedule
shared_examples 'successful scheduling' do
it 'creates a new pipeline' do
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
it 'updates the next_run_at field' do
subject
it_behaves_like 'successful scheduling'
expect(pipeline_schedule.reload.next_run_at).to be > Time.now
end
context 'when the latest commit contains [ci skip]' do
before do
allow_any_instance_of(Ci::Pipeline)
.to receive(:git_commit_message)
.and_return('some commit [ci skip]')
end
it 'sets the schedule on the pipeline' do
subject
expect(project.pipelines.last.pipeline_schedule).to eq(pipeline_schedule)
it_behaves_like 'successful scheduling'
end
end
context 'inactive schedule' do
context 'when the schedule is deactivated' do
before do
pipeline_schedule.deactivate!
end