diff options
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/models/commit.rb | 2 | ||||
-rw-r--r-- | app/services/create_commit_service.rb | 2 | ||||
-rw-r--r-- | spec/models/commit_spec.rb | 27 |
4 files changed, 28 insertions, 4 deletions
@@ -1,6 +1,7 @@ v7.10.0 - Projects sorting by last commit date - Add project search at runner page + - Ability to run deploy job without test jobs (every push will trigger deploy job) v7.9.1 - [Security] Adding explicit is_shared parameter to runner diff --git a/app/models/commit.rb b/app/models/commit.rb index 2e1bd52..32bd334 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -137,7 +137,7 @@ class Commit < ActiveRecord::Base end def create_deploy_builds(ref) - if success? && !last_build.job.deploy? + if builds.empty? || (success? && !last_build.job.deploy?) project.jobs.deploy.active.each do |job| if job.run_for_ref?(ref) create_build_from_job(job) diff --git a/app/services/create_commit_service.rb b/app/services/create_commit_service.rb index e2e7053..9c8906f 100644 --- a/app/services/create_commit_service.rb +++ b/app/services/create_commit_service.rb @@ -48,6 +48,8 @@ class CreateCommitService commit.create_builds end + commit.create_deploy_builds(ref) + commit end end diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index da57109..78be635 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -159,19 +159,40 @@ describe Commit do end describe "create_deploy_builds" do - before do + it "creates deploy build for projects without test jobs" do + FactoryGirl.create :job, job_type: :deploy, project: project + project.reload + + commit.create_deploy_builds(commit.ref) + commit.builds.reload + + commit.builds.size.should == 1 + end + + it "creates new build for deploy if all jobs succeed" do job = FactoryGirl.create :job, project: project job1 = FactoryGirl.create :job, project: project FactoryGirl.create :job, job_type: :deploy, project: project FactoryGirl.create :build, commit: commit, status: :success, job: job FactoryGirl.create :build, commit: commit, status: :success, job: job1 project.reload - end - it "creates new build for deploy" do commit.create_deploy_builds(commit.ref) commit.builds.size.should == 3 end + + it "does not create deploy build if one job failed" do + job = FactoryGirl.create :job, project: project + job1 = FactoryGirl.create :job, project: project + FactoryGirl.create :job, job_type: :deploy, project: project + FactoryGirl.create :build, commit: commit, status: :failed, job: job + FactoryGirl.create :build, commit: commit, status: :success, job: job1 + project.reload + + commit.create_deploy_builds(commit.ref) + + commit.builds.size.should == 2 + end end end |