class Object

Public Instance Methods

job(stage_name, name) click to toggle source
# File lib/rspec/pipeline/helper.rb, line 23
def job(stage_name, name)
  job = stage(stage_name)['jobs'].find { |item| item['job'] == name }

  raise "Job not found: #{name}" if job.nil?

  job['blockType'] = 'Job'
  job['blockName'] = job['job']

  job
end
pipeline() click to toggle source
# File lib/rspec/pipeline/helper.rb, line 6
def pipeline
  pipeline = RSpec::Pipeline::PipelineLoader.new(pipeline_name)

  pipeline.load
end
pull_request() click to toggle source
# File lib/rspec/pipeline/helper.rb, line 60
def pull_request
  # TODO
end
push_to_branch(name) click to toggle source

events

# File lib/rspec/pipeline/helper.rb, line 48
def push_to_branch(name)
  {
    'type' => :push,
    'branch' => name,
    'condition' => "eq(variables['build.sourceBranch'], 'refs/heads/#{name}'"
  }
end
push_to_master() click to toggle source
# File lib/rspec/pipeline/helper.rb, line 56
def push_to_master
  push_to_branch 'master'
end
stage(name) click to toggle source
# File lib/rspec/pipeline/helper.rb, line 12
def stage(name)
  stage = pipeline['stages'].find { |item| item['stage'] == name }

  raise "Stage not found: #{name}" if stage.nil?

  stage['blockType'] = 'Stage'
  stage['blockName'] = stage['stage']

  stage
end
step(stage_name, job_name, name) click to toggle source
# File lib/rspec/pipeline/helper.rb, line 34
def step(stage_name, job_name, name)
  job_to_search = job(stage_name, job_name)
  raise "Job #{job_name} doesn't have steps" unless job_to_search['steps']

  step = job_to_search['steps'].find { |item| item['name'] == name }
  raise "Step not found: #{name} (available: #{job_to_search['steps'].map { |item| item['name'] }})" if step.nil?

  step['blockType'] = 'Step'
  step['blockName'] = step['name']

  step
end