Commit b9ed15e2 authored by Grzegorz Bizon's avatar Grzegorz Bizon Committed by Douglas Barbosa Alexandre

Merge branch 'fix/import-export-build-token' into 'master'

Fix duplicated build token problem importing projects

Reset token so duplicated builds do not thrown an error on import

- [x] [Changelog entry](https://docs.gitlab.com/ce/development/changelog.html) added
- Tests
  - [x] Added for this feature/bug
  - [x] All builds are passing
- [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if it does - rebase it please)
- [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/23475

See merge request !8171
parent e38a6f4a
---
title: Fix Import/Export duplicated builds error
merge_request:
author:
......@@ -101,6 +101,8 @@ module Gitlab
def generate_imported_object
if BUILD_MODELS.include?(@relation_name) # call #trace= method after assigning the other attributes
trace = @relation_hash.delete('trace')
@relation_hash.delete('token')
imported_object do |object|
object.trace = trace
object.commit_id = nil
......
......@@ -6548,7 +6548,9 @@
"url": null
},
"erased_by_id": null,
"erased_at": null
"erased_at": null,
"type": "Ci::Build",
"token": "abcd"
},
{
"id": 72,
......
......@@ -189,6 +189,14 @@ describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do
end
end
end
context 'when there is an existing build with build token' do
it 'restores project json correctly' do
create(:ci_build, token: 'abcd')
expect(restored_project_json).to be true
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment