Class: LabClient::Generator::PipelineTrigger

Inherits:
GroupTemplateHelper show all
Defined in:
lib/labclient/generator/templates/pipeline_trigger.rb

Overview

Child and other Trigger Examples docs.gitlab.com/ee/ci/yaml/#trigger

Instance Attribute Summary

Attributes inherited from GroupTemplateHelper

#group_name, #group_path, #group_suffix, #project_name

Attributes inherited from TemplateHelper

#client, #opts

Instance Method Summary collapse

Methods inherited from GroupTemplateHelper

#generate_group, #run!, #setup

Methods included from Names

#create_file, #gen_description, #gen_groups, #gen_people, #gen_projects, #generate_names

Methods inherited from TemplateHelper

#initialize, #inspect, #setup

Constructor Details

This class inherits a constructor from LabClient::Generator::TemplateHelper

Instance Method Details

#child_pipeline_yamlObject



49
50
51
52
53
54
55
56
57
# File 'lib/labclient/generator/templates/pipeline_trigger.rb', line 49

def child_pipeline_yaml
  <<~YAML
    image: busybox:latest

    child:
      script:
        - echo "Do your build here"
  YAML
end

#create_child_pipelineObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/labclient/generator/templates/pipeline_trigger.rb', line 59

def create_child_pipeline
  project = @group.project_create(
    name: 'Child Pipeline',
    description: 'Child Pipeline',
    auto_devops_enabled: false
  )

  # Create Child
  project.file_create(
    'child_pipeline.yml',
    create_file(child_pipeline_yaml)
  )

  # Create Parent
  project.file_create(
    '.gitlab-ci.yml',
    create_file(trigger_child_pipeline_yaml)
  )

  @projects.push project
end

#setup_projectsObject



23
24
25
# File 'lib/labclient/generator/templates/pipeline_trigger.rb', line 23

def setup_projects
  create_child_pipeline
end

#trigger_child_pipeline_yamlObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/labclient/generator/templates/pipeline_trigger.rb', line 27

def trigger_child_pipeline_yaml
  <<~YAML
    image: busybox:latest

    build_child:
      stage: build
      script:
        - cp child_pipeline.yml artifact.yml
      artifacts:
        paths:
          - artifact.yml

    trigger_child:
      stage: deploy
      trigger:
        include:
          - artifact: artifact.yml
            job: build_child

  YAML
end