summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-07-18 08:24:15 +0000
committerRémy Coutable <remy@rymai.me>2016-07-18 08:24:15 +0000
commit7af92af5fe2a7c5c4be91d0d6daea61fc032d6f4 (patch)
tree8abd78b0dcea5eaad073d8056fb42c86e38b2c16
parent3f643a38c07d89b83572c7f9930a005389de8ee2 (diff)
parent72818f2c1573b7664d4b41692dc51db1e5c28fbb (diff)
downloadgitlab-ce-7af92af5fe2a7c5c4be91d0d6daea61fc032d6f4.tar.gz
Merge branch 'fix-deployment-creation-on-build-retry' into 'master'
Fix creation of deployment on build that is retried, redeployed or rollback ## What does this MR do? Add missing `environment` to be copied when retrying a build. ## Why was this MR needed? The retried builds did not create a deployments. ## What are the relevant issue numbers? Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/19521 - [ ] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md) - [ ] API support added - Tests - [ ] Added for this feature/bug - [ ] All builds are passing - [ ] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [ ] Branch has no merge conflicts with `master` (if you do - rebase it please) - [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !5275
-rw-r--r--CHANGELOG1
-rw-r--r--app/models/ci/build.rb1
-rw-r--r--spec/services/create_deployment_service_spec.rb16
3 files changed, 18 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 2ae6af7ab6b..16899f775fb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -61,6 +61,7 @@ v 8.10.0 (unreleased)
- Allow expanding and collapsing files in diff view (!4990)
- Collapse large diffs by default (!4990)
- Fix mentioned users list on diff notes
+ - Fix creation of deployment on build that is retried, redeployed or rollback
- Check for conflicts with existing Project's wiki path when creating a new project.
- Show last push widget in upstream after push to fork
- Fix stage status shown for pipelines
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index e189dbac285..b24527247e0 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -53,6 +53,7 @@ module Ci
new_build.stage_idx = build.stage_idx
new_build.trigger_request = build.trigger_request
new_build.user = user
+ new_build.environment = build.environment
new_build.save
MergeRequests::AddTodoWhenBuildFailsService.new(build.project, nil).close(new_build)
new_build
diff --git a/spec/services/create_deployment_service_spec.rb b/spec/services/create_deployment_service_spec.rb
index 654e441f3cd..8da2a2b3c1b 100644
--- a/spec/services/create_deployment_service_spec.rb
+++ b/spec/services/create_deployment_service_spec.rb
@@ -89,6 +89,12 @@ describe CreateDeploymentService, services: true do
expect_any_instance_of(described_class).to receive(:execute)
subject
end
+
+ it 'is set as deployable' do
+ subject
+
+ expect(Deployment.last.deployable).to eq(deployable)
+ end
end
context 'without environment specified' do
@@ -105,6 +111,8 @@ describe CreateDeploymentService, services: true do
context 'when build succeeds' do
it_behaves_like 'does create environment and deployment' do
+ let(:deployable) { build }
+
subject { build.success }
end
end
@@ -114,6 +122,14 @@ describe CreateDeploymentService, services: true do
subject { build.drop }
end
end
+
+ context 'when build is retried' do
+ it_behaves_like 'does create environment and deployment' do
+ let(:deployable) { Ci::Build.retry(build) }
+
+ subject { deployable.success }
+ end
+ end
end
end
end