class LabClient::Generator::Environments
Child and other Trigger Examples docs.gitlab.com/ee/ci/yaml/#trigger
Public Instance Methods
on_stop_yaml()
click to toggle source
# File lib/labclient/generator/templates/environments.rb, line 21 def on_stop_yaml <<~YAML image: busybox:latest build: stage: build script: - echo "Build on both master and branches" branch-review: stage: deploy environment: name: ${CI_COMMIT_REF_NAME} on_stop: review-teardown script: - echo "branch-review" only: - branches except: - master review-teardown: stage: deploy when: manual variables: GIT_STRATEGY: none environment: name: ${CI_COMMIT_REF_NAME} action: stop script: - echo "review-teardown" only: - branches except: - master YAML end
setup_master_branch_environment_on_stop()
click to toggle source
rubocop:disable Metrics/MethodLength
# File lib/labclient/generator/templates/environments.rb, line 60 def setup_master_branch_environment_on_stop project = @group.project_create( name: 'On Stop', description: 'Environments created on non-master branches, stopped on merge', auto_devops_enabled: false, only_allow_merge_if_pipeline_succeeds: true ) # Create Parent project.file_create('README.md', create_file("# #{project.name}")) # # Create Branch project.branch_create(branch: :branch, ref: :master) # Create Branch Files project.file_create('.gitlab-ci.yml', create_file(on_stop_yaml, :branch)) # Create Merge Request merge_request = project.merge_request_create( title: 'Merge Test Branch!', source_branch: :branch, target_branch: :master ) # Wait for Merge merge_request.wait_for_merge_status # Merge merge_request.accept( should_remove_source_branch: true, merge_when_pipeline_succeeds: true ) @projects.push project end