Class: BasicPipeline
- Inherits:
-
PipelineDefinition
- Object
- PipelineDefinition
- BasicPipeline
- Defined in:
- app/models/basic_pipeline.rb
Instance Attribute Summary
Attributes inherited from PipelineDefinition
Instance Method Summary collapse
Methods inherited from PipelineDefinition
as_json, #create_job, ensure_stage, ensure_stages, #initialize, #next, #project, #project=, #save, stage, #stage, stage_options, stages, start, trigger_when?, #variables
Constructor Details
This class inherits a constructor from PipelineDefinition
Instance Method Details
#basic_job_from_file ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/models/basic_pipeline.rb', line 23 def basic_job_from_file ci_file = project.owner.client.file(project.repo_name, 'ci.yml') if ci_file spec = {} build = HashWithIndifferentAccess.new(YAML.load(ci_file)) # services are copied directly spec[:services] = build[:services] # turns each key into a section spec[:sections] = [] spec[:sections] << { name: 'setup', fail_on_err: true, commands: build[:setup], on_success: build[:on_success], on_failure: build[:on_failure], } spec[:sections] << { name: 'test', fail_on_err: true, commands: build[:test], on_success: build[:on_success], on_failure: build[:on_failure], } spec[:sections] << { name: 'after', fail_on_err: true, commands: build[:after], } spec else { sections: [ { name: 'test', fail_on_err: true, commands: ['exit 1'], } ] } end end |
#first ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/models/basic_pipeline.rb', line 4 def first scm = {} if event.data[:commit] scm[:commit] = event.data[:commit] scm[:branch] = event.data[:branch] scm[:pull_request] = event.data[:pull_request] else latest = project.owner.client.latest_commit(project.repo_name) scm[:commit] = latest[:sha] scm[:branch] = latest[:branch] end create_job( project: project, scm: scm, spec: basic_job_from_file, ) end |