Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Commit

Permalink
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
dzaporozhets committed Apr 3, 2015
2 parents 2aa77d1 + ecb5705 commit 1bb72f8
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ v7.10.0

v7.9.2
- [Security] Already existing projects should not be served by shared runners
- 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
Expand Down
5 changes: 4 additions & 1 deletion app/models/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ def retry(build)
WebHookService.new.build_end(build)
end

build.commit.create_deploy_builds(build.ref)
if build.commit.success? && !build.job.deploy?
build.commit.create_deploy_builds(build.ref)
end

project.execute_services(build)

if project.coverage_enabled?
Expand Down
8 changes: 3 additions & 5 deletions app/models/commit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,9 @@ def retried_builds
end

def create_deploy_builds(ref)
if success? && !last_build.job.deploy?
project.jobs.deploy.active.each do |job|
if job.run_for_ref?(ref)
create_build_from_job(job)
end
project.jobs.deploy.active.each do |job|
if job.run_for_ref?(ref)
create_build_from_job(job)
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions app/services/create_commit_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def execute(project, params)
commit.create_builds
end

if commit.builds.empty?
commit.create_deploy_builds(ref)
end

commit
end
end
11 changes: 3 additions & 8 deletions spec/models/commit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,14 @@
end

describe "create_deploy_builds" do
before do
job = FactoryGirl.create :job, project: project
job1 = FactoryGirl.create :job, project: project
it "creates deploy build" do
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.reload

commit.builds.size.should == 3
commit.builds.size.should == 1
end
end
end
13 changes: 13 additions & 0 deletions spec/services/create_commit_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,18 @@

it { should be_false }
end

context "deploy builds" do
it "calls create_deploy_builds if there are no builds" do
project.jobs.destroy_all
Commit.any_instance.should_receive(:create_deploy_builds)
service.execute(project, ref: 'refs/heads/master', before: '00000000', after: '31das312')
end

it "does not call create_deploy_builds if there is build" do
Commit.any_instance.should_not_receive(:create_deploy_builds)
service.execute(project, ref: 'refs/heads/master', before: '00000000', after: '31das312')
end
end
end
end

0 comments on commit 1bb72f8

Please sign in to comment.