summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-11-12 20:14:14 +0000
committerStan Hu <stanhu@gmail.com>2018-11-12 20:14:14 +0000
commit8f60a8ba8d2e518088194483233582b80fc1a5d7 (patch)
tree2167fda11473912041f94b517060cf76a0e7f39e
parent33cd8efbd7db768057ae87b97566733a6eed7997 (diff)
parent08ef7b9fe8595ab6695418108420f079dbd73694 (diff)
downloadgitlab-ce-8f60a8ba8d2e518088194483233582b80fc1a5d7.tar.gz
Merge branch 'fix-tags-for-envs' into 'master'
Fix tags for environments Closes gitlab-ee#8397 See merge request gitlab-org/gitlab-ce!22993
-rw-r--r--app/models/concerns/deployable.rb7
-rw-r--r--changelogs/unreleased/fix-tags-for-envs.yml5
-rw-r--r--spec/services/ci/create_pipeline_service_spec.rb13
3 files changed, 18 insertions, 7 deletions
diff --git a/app/models/concerns/deployable.rb b/app/models/concerns/deployable.rb
index f4f1989f0a9..85db01af18d 100644
--- a/app/models/concerns/deployable.rb
+++ b/app/models/concerns/deployable.rb
@@ -13,17 +13,14 @@ module Deployable
name: expanded_environment_name
)
- environment.deployments.create!(
+ create_deployment!(
project_id: environment.project_id,
environment: environment,
ref: ref,
tag: tag,
sha: sha,
user: user,
- deployable: self,
- on_stop: on_stop).tap do |_|
- self.reload # Reload relationships
- end
+ on_stop: on_stop)
end
end
end
diff --git a/changelogs/unreleased/fix-tags-for-envs.yml b/changelogs/unreleased/fix-tags-for-envs.yml
new file mode 100644
index 00000000000..633788ff6d8
--- /dev/null
+++ b/changelogs/unreleased/fix-tags-for-envs.yml
@@ -0,0 +1,5 @@
+---
+title: Do not reload self on hooks when creating deployment
+merge_request:
+author:
+type: fixed
diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb
index 5c87ed5c3c6..193148d403a 100644
--- a/spec/services/ci/create_pipeline_service_spec.rb
+++ b/spec/services/ci/create_pipeline_service_spec.rb
@@ -387,15 +387,24 @@ describe Ci::CreatePipelineService do
context 'with environment' do
before do
- config = YAML.dump(deploy: { environment: { name: "review/$CI_COMMIT_REF_NAME" }, script: 'ls' })
+ config = YAML.dump(
+ deploy: {
+ environment: { name: "review/$CI_COMMIT_REF_NAME" },
+ script: 'ls',
+ tags: ['hello']
+ })
+
stub_ci_pipeline_yaml_file(config)
end
- it 'creates the environment' do
+ it 'creates the environment with tags' do
result = execute_service
expect(result).to be_persisted
expect(Environment.find_by(name: "review/master")).to be_present
+ expect(result.builds.first.tag_list).to contain_exactly('hello')
+ expect(result.builds.first.deployment).to be_persisted
+ expect(result.builds.first.deployment.deployable).to be_a(Ci::Build)
end
end