summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-10-09 11:10:00 +0200
committerKamil Trzciński <ayufan@ayufan.eu>2018-10-09 11:10:00 +0200
commitbfea8c35c0b7de22729342470b28c99f238c55d2 (patch)
tree691931b36cae2e44f63b6aa7837a053d754785ed
parente5f94a3f4f964b6b15542937d24f8c4cb8d6adba (diff)
downloadgitlab-ce-split-create-and-populate-pipelines.tar.gz
Support bootstrap artifactsplit-create-and-populate-pipelines
-rw-r--r--app/models/ci/build.rb16
-rw-r--r--app/models/ci/job_artifact.rb11
-rw-r--r--app/services/ci/populate_pipeline_service.rb2
3 files changed, 24 insertions, 5 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index a59ff731954..5d61696aa71 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -184,6 +184,18 @@ module Ci
end
end
+ after_transition any => [:success] do |build|
+ if build.bootstrap? && build.job_artifacts_gitlab_ci_yaml
+ # very hacky way to inject ci_yaml_file!
+ build.job_artifacts_gitlab_ci_yaml.each_blob do |blob|
+ build.pipeline.instance_variable_set(:@ci_yaml_file, blob)
+ end
+
+ Ci::PopulatePipelineService.new(build.project, build.user).execute(
+ build.pipeline, nil, nil, save_on_errors: true)
+ end
+ end
+
before_transition any => [:failed] do |build|
next unless build.project
next if build.retries_max.zero?
@@ -832,5 +844,9 @@ module Ci
def project_destroyed?
project.pending_delete?
end
+
+ def bootstrap?
+ self.name = 'bootstrap'
+ end
end
end
diff --git a/app/models/ci/job_artifact.rb b/app/models/ci/job_artifact.rb
index cb73fc74bb6..c6d53447ca5 100644
--- a/app/models/ci/job_artifact.rb
+++ b/app/models/ci/job_artifact.rb
@@ -9,7 +9,7 @@ module Ci
NotSupportedAdapterError = Class.new(StandardError)
TEST_REPORT_FILE_TYPES = %w[junit].freeze
- NON_ERASABLE_FILE_TYPES = %w[trace].freeze
+ NON_ERASABLE_FILE_TYPES = %w[trace gitlab_ci_yaml].freeze
DEFAULT_FILE_NAMES = {
archive: nil,
metadata: nil,
@@ -19,7 +19,8 @@ module Ci
sast: 'gl-sast-report.json',
dependency_scanning: 'gl-dependency-scanning-report.json',
container_scanning: 'gl-container-scanning-report.json',
- dast: 'gl-dast-report.json'
+ dast: 'gl-dast-report.json',
+ gitlab_ci_yaml: 'gitlab-ci.yml'
}.freeze
TYPE_AND_FORMAT_PAIRS = {
@@ -31,7 +32,8 @@ module Ci
sast: :gzip,
dependency_scanning: :gzip,
container_scanning: :gzip,
- dast: :gzip
+ dast: :gzip,
+ gitlab_ci_yaml: :gzip
}.freeze
belongs_to :project
@@ -76,7 +78,8 @@ module Ci
dependency_scanning: 6, ## EE-specific
container_scanning: 7, ## EE-specific
dast: 8, ## EE-specific
- codequality: 9 ## EE-specific
+ codequality: 9, ## EE-specific
+ gitlab_ci_yaml: 10
}
enum file_format: {
diff --git a/app/services/ci/populate_pipeline_service.rb b/app/services/ci/populate_pipeline_service.rb
index 0e950e977ff..f1096a5c6d5 100644
--- a/app/services/ci/populate_pipeline_service.rb
+++ b/app/services/ci/populate_pipeline_service.rb
@@ -26,7 +26,7 @@ module Ci
sequence.build! do |pipeline, sequence|
if sequence.complete?
- complete_block.call
+ complete_block.call if complete_block
pipeline.process!
end
end