From 70e9966639d7da9abc70e22814b3716eaca5d0c0 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Fri, 5 Jun 2015 14:23:42 +0300 Subject: Do not retry build for the same commit and ref --- app/services/create_commit_service.rb | 2 +- spec/services/create_commit_service_spec.rb | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app/services/create_commit_service.rb b/app/services/create_commit_service.rb index bcd7a63..81d552a 100644 --- a/app/services/create_commit_service.rb +++ b/app/services/create_commit_service.rb @@ -54,7 +54,7 @@ class CreateCommitService commit = project.commits.create(data) end - commit.create_builds + commit.create_builds unless commit.builds.any? if commit.builds.empty? commit.create_deploy_builds diff --git a/spec/services/create_commit_service_spec.rb b/spec/services/create_commit_service_spec.rb index 4b4f788..ae118e4 100644 --- a/spec/services/create_commit_service_spec.rb +++ b/spec/services/create_commit_service_spec.rb @@ -97,5 +97,26 @@ describe CreateCommitService do result.should be_persisted end end + + it "skips build creation if there are already builds" do + commits = [{message: "message"}] + commit = service.execute(project, + ref: 'refs/heads/master', + before: '00000000', + after: '31das312', + commits: commits, + ci_yaml_file: gitlab_ci_yaml + ) + commit.builds.count(:all).should == 2 + + commit = service.execute(project, + ref: 'refs/heads/master', + before: '00000000', + after: '31das312', + commits: commits, + ci_yaml_file: gitlab_ci_yaml + ) + commit.builds.count(:all).should == 2 + end end end -- cgit v1.2.1 From 95a081317df12302baa6873749bb0b435062edb2 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Fri, 5 Jun 2015 14:27:02 +0300 Subject: update changelog --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index cfccbc2..7c85a5e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ v7.12.0 - Increase default timeout for builds to 60 minutes - Using .gitlab-ci.yml file instead of jobs - Link to the runner from the build page for admin user + - Dont retry build when push same commit in same ref twice v7.11.0 - Deploy Jobs API calls -- cgit v1.2.1