brpm_content 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +38 -0
- data/.travis.yml +14 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +308 -0
- data/Rakefile +24 -0
- data/TO_BE_MIGRATED.txt +8 -0
- data/architecture.png +0 -0
- data/brpm_content.gemspec +31 -0
- data/customers/demo/integrations/brpm/process_event_handler_event.rb +183 -0
- data/customers/demo/integrations/jenkins/spec/api/applications_spec.rb +89 -0
- data/customers/demo/integrations/jenkins/spec/api/plans_spec.rb +69 -0
- data/customers/demo/integrations/jenkins/spec/api/requests_spec.rb +57 -0
- data/customers/demo/integrations/jenkins/spec/spec_helper.rb +33 -0
- data/customers/demo/integrations/jira/process_webhook_event.rb +33 -0
- data/customers/demo/jira_mappings.rb +29 -0
- data/infrastructure/integrations/event_handler.rb +62 -0
- data/infrastructure/integrations/webhook_receiver.rb +49 -0
- data/infrastructure/shell_scripts/backup_database.sh +19 -0
- data/infrastructure/shell_scripts/create_bl_package.sh +34 -0
- data/infrastructure/shell_scripts/create_release_request.sh +34 -0
- data/infrastructure/shell_scripts/ddns.sh +10 -0
- data/infrastructure/shell_scripts/install_brpm.sh +63 -0
- data/infrastructure/shell_scripts/install_content_module.sh +66 -0
- data/infrastructure/shell_scripts/install_content_repo.sh +60 -0
- data/infrastructure/shell_scripts/install_module_from_gem.sh +80 -0
- data/infrastructure/shell_scripts/maintenance.sh +4 -0
- data/infrastructure/shell_scripts/patch_brpm.sh +90 -0
- data/infrastructure/shell_scripts/restore_database.sh +33 -0
- data/infrastructure/shell_scripts/run_event_handler.cmd +16 -0
- data/infrastructure/shell_scripts/run_event_handler.sh +20 -0
- data/infrastructure/shell_scripts/run_webhook_receiver.cmd +14 -0
- data/infrastructure/shell_scripts/run_webhook_receiver.sh +15 -0
- data/infrastructure/shell_scripts/update_content_repo.sh +21 -0
- data/infrastructure/silent_install_options_4.6.txt +93 -0
- data/infrastructure/silent_install_options_upgrade_4.6.txt +92 -0
- data/infrastructure/smtp_settings.rb +42 -0
- data/infrastructure/ssh_script_header_additions.rb +21 -0
- data/modules/ansible/automations/execute_role.rb +3 -0
- data/modules/ansible/automations/execute_role.txt +12 -0
- data/modules/ansible/config.yml +5 -0
- data/modules/ansible/lib/ansible.rb +41 -0
- data/modules/atrium_orchestrator/automations/execute_workflow.rb +12 -0
- data/modules/atrium_orchestrator/automations/execute_workflow.txt +25 -0
- data/modules/atrium_orchestrator/automations/reserve_ip_address.rb +22 -0
- data/modules/atrium_orchestrator/automations/reserve_ip_address.txt +21 -0
- data/modules/atrium_orchestrator/config.yml +7 -0
- data/modules/atrium_orchestrator/lib/ao_soap_client.rb +94 -0
- data/modules/bladelogic/automations/create_package.rb +29 -0
- data/modules/bladelogic/automations/create_package.txt +26 -0
- data/modules/bladelogic/automations/deploy_package.rb +137 -0
- data/modules/bladelogic/automations/deploy_package.txt +53 -0
- data/modules/bladelogic/config.yml +7 -0
- data/modules/bladelogic/lib/bl_rest/bsa_rest_client.rb +65 -0
- data/modules/bladelogic/lib/bl_soap/blpackage.rb +43 -0
- data/modules/bladelogic/lib/bl_soap/bsa_soap_base.rb +118 -0
- data/modules/bladelogic/lib/bl_soap/bsa_soap_client.rb +34 -0
- data/modules/bladelogic/lib/bl_soap/compliance_job.rb +155 -0
- data/modules/bladelogic/lib/bl_soap/deploy_job.rb +48 -0
- data/modules/bladelogic/lib/bl_soap/depot_group.rb +47 -0
- data/modules/bladelogic/lib/bl_soap/job.rb +376 -0
- data/modules/bladelogic/lib/bl_soap/job_group.rb +72 -0
- data/modules/bladelogic/lib/bl_soap/job_management.rb +22 -0
- data/modules/bladelogic/lib/bl_soap/job_result.rb +12 -0
- data/modules/bladelogic/lib/bl_soap/job_run.rb +271 -0
- data/modules/bladelogic/lib/bl_soap/login.rb +47 -0
- data/modules/bladelogic/lib/bl_soap/nsh_script_job.rb +14 -0
- data/modules/bladelogic/lib/bl_soap/patch_catalog.rb +178 -0
- data/modules/bladelogic/lib/bl_soap/patch_remediation_job.rb +137 -0
- data/modules/bladelogic/lib/bl_soap/patching_job.rb +250 -0
- data/modules/bladelogic/lib/bl_soap/server.rb +12 -0
- data/modules/bladelogic/lib/bl_soap/template.rb +13 -0
- data/modules/bladelogic/lib/bl_soap/utility.rb +99 -0
- data/modules/bladelogic/resource_automations/select_job.rb +33 -0
- data/modules/bladelogic/resource_automations/select_job.txt +15 -0
- data/modules/bladelogic/tests/create_package_spec.rb +28 -0
- data/modules/bladelogic/tests/deploy_package_spec.rb +23 -0
- data/modules/bladelogic/tests/spec_helper.rb +82 -0
- data/modules/brpm/automations/create_release_from_excel.rb +34 -0
- data/modules/brpm/automations/create_release_from_excel.txt +5 -0
- data/modules/brpm/automations/create_release_request.rb +100 -0
- data/modules/brpm/automations/create_release_request.txt +5 -0
- data/modules/brpm/automations/create_request.rb +73 -0
- data/modules/brpm/automations/create_request.txt +23 -0
- data/modules/brpm/automations/promote_request.rb +197 -0
- data/modules/brpm/automations/promote_request.txt +24 -0
- data/modules/brpm/automations/select_application_version.rb +22 -0
- data/modules/brpm/automations/select_application_version.txt +17 -0
- data/modules/brpm/automations/select_component_version.rb +12 -0
- data/modules/brpm/automations/select_component_version.txt +5 -0
- data/modules/brpm/automations/select_request_template.rb +6 -0
- data/modules/brpm/automations/select_request_template.txt +13 -0
- data/modules/brpm/automations/wait_for_step_in_other_request.rb +11 -0
- data/modules/brpm/automations/wait_for_step_in_other_request.txt +13 -0
- data/modules/brpm/automations/wait_till_promoted_request_is_completed.rb +9 -0
- data/modules/brpm/automations/wait_till_promoted_request_is_completed.txt +5 -0
- data/modules/brpm/config.yml +6 -0
- data/modules/brpm/lib/brpm_request.rb +207 -0
- data/modules/brpm/lib/brpm_rest.rb +312 -0
- data/modules/brpm/lib/brpm_rest_client.rb +1501 -0
- data/modules/brpm/resource_automations/select_application.rb +16 -0
- data/modules/brpm/resource_automations/select_application.txt +5 -0
- data/modules/brpm/resource_automations/select_environment.rb +14 -0
- data/modules/brpm/resource_automations/select_environment.txt +5 -0
- data/modules/brpm/resource_automations/select_request_template.rb +16 -0
- data/modules/brpm/resource_automations/select_request_template.txt +5 -0
- data/modules/brpm/resource_automations/select_step_in_request.rb +33 -0
- data/modules/brpm/resource_automations/select_step_in_request.txt +5 -0
- data/modules/brpm/sample_applications/e-finance.json +0 -0
- data/modules/brpm/tests/create_release_request_spec.rb +66 -0
- data/modules/brpm/tests/create_request_spec.rb +84 -0
- data/modules/brpm/tests/select_application_version_spec.rb +47 -0
- data/modules/brpm/tests/spec_helper.rb +63 -0
- data/modules/docker_brpm/automations/create_brpm_instance_input_params.rb +10 -0
- data/modules/docker_brpm/automations/create_brpm_instance_input_params.txt +17 -0
- data/modules/docker_brpm/automations/create_brpm_instance_one_shot.rb +60 -0
- data/modules/docker_brpm/automations/create_brpm_instance_one_shot.txt +14 -0
- data/modules/docker_brpm/automations/create_brpm_instance_show_results.rb +23 -0
- data/modules/docker_brpm/automations/create_brpm_instance_show_results.txt +13 -0
- data/modules/docker_brpm/automations/create_database.rb +24 -0
- data/modules/docker_brpm/automations/create_database.txt +3 -0
- data/modules/docker_brpm/automations/create_environment.rb +14 -0
- data/modules/docker_brpm/automations/create_environment.txt +3 -0
- data/modules/docker_brpm/automations/create_image_for_application.rb +23 -0
- data/modules/docker_brpm/automations/create_image_for_application.txt +6 -0
- data/modules/docker_brpm/automations/create_image_for_brpm_application_input_params.rb +7 -0
- data/modules/docker_brpm/automations/create_image_for_brpm_application_input_params.txt +8 -0
- data/modules/docker_brpm/automations/create_image_for_brpm_database_creator_input_params.rb +7 -0
- data/modules/docker_brpm/automations/create_image_for_brpm_database_creator_input_params.txt +8 -0
- data/modules/docker_brpm/automations/create_image_for_database_creator.rb +21 -0
- data/modules/docker_brpm/automations/create_image_for_database_creator.txt +6 -0
- data/modules/docker_brpm/automations/create_installed_component_for_application.rb +11 -0
- data/modules/docker_brpm/automations/create_installed_component_for_application.txt +3 -0
- data/modules/docker_brpm/automations/create_installed_component_for_database.rb +7 -0
- data/modules/docker_brpm/automations/create_installed_component_for_database.txt +3 -0
- data/modules/docker_brpm/automations/create_installed_component_for_database_creator.rb +8 -0
- data/modules/docker_brpm/automations/create_installed_component_for_database_creator.txt +3 -0
- data/modules/docker_brpm/automations/create_installed_component_for_utilities.rb +7 -0
- data/modules/docker_brpm/automations/create_installed_component_for_utilities.txt +3 -0
- data/modules/docker_brpm/automations/create_version_tags_for_component_in_all_envs.rb +13 -0
- data/modules/docker_brpm/automations/create_version_tags_for_component_in_all_envs.txt +6 -0
- data/modules/docker_brpm/automations/delete_brpm_instance.rb +38 -0
- data/modules/docker_brpm/automations/delete_brpm_instance.txt +8 -0
- data/modules/docker_brpm/automations/execute_test_run_in_jenkins.rb +43 -0
- data/modules/docker_brpm/automations/execute_test_run_in_jenkins.txt +13 -0
- data/modules/docker_brpm/automations/execute_test_run_in_jenkins_show_results.rb +5 -0
- data/modules/docker_brpm/automations/execute_test_run_in_jenkins_show_results.txt +9 -0
- data/modules/docker_brpm/automations/launch_create_image_for_brpm_application_request.rb +27 -0
- data/modules/docker_brpm/automations/launch_create_image_for_brpm_application_request.txt +3 -0
- data/modules/docker_brpm/automations/launch_test_run_request.rb +30 -0
- data/modules/docker_brpm/automations/launch_test_run_request.txt +14 -0
- data/modules/docker_brpm/automations/release_brpm_input_params.rb +7 -0
- data/modules/docker_brpm/automations/release_brpm_input_params.txt +8 -0
- data/modules/docker_brpm/automations/run_application_container.rb +27 -0
- data/modules/docker_brpm/automations/run_application_container.txt +3 -0
- data/modules/docker_brpm/automations/run_database_container.rb +14 -0
- data/modules/docker_brpm/automations/run_database_container.txt +3 -0
- data/modules/docker_brpm/automations/stop_application_container.rb +11 -0
- data/modules/docker_brpm/automations/stop_application_container.txt +3 -0
- data/modules/docker_brpm/automations/stop_database_container.rb +11 -0
- data/modules/docker_brpm/automations/stop_database_container.txt +3 -0
- data/modules/docker_brpm/automations/test_rest_api.rb +18 -0
- data/modules/docker_brpm/automations/test_rest_api.txt +3 -0
- data/modules/docker_brpm/automations/upgrade_database.rb +19 -0
- data/modules/docker_brpm/automations/upgrade_database.txt +8 -0
- data/modules/docker_brpm/config.yml +8 -0
- data/modules/docker_brpm/lib/docker.rb +39 -0
- data/modules/docker_brpm/lib/git.rb +16 -0
- data/modules/docker_brpm/sample_applications/dockerizedbrpm.json +0 -0
- data/modules/email/automations/send_notification.rb +48 -0
- data/modules/email/automations/send_notification.txt +27 -0
- data/modules/email/config.yml +6 -0
- data/modules/framework/automations/direct_execute.rb +10 -0
- data/modules/framework/automations/direct_execute.txt +16 -0
- data/modules/framework/automations/install_module.rb +13 -0
- data/modules/framework/automations/install_module.txt +16 -0
- data/modules/framework/bin/brpm_install +106 -0
- data/modules/framework/bin/event_handler +63 -0
- data/modules/framework/bin/webhook_receiver +49 -0
- data/modules/framework/brpm_auto.rb +307 -0
- data/modules/framework/brpm_framework.rb +88 -0
- data/modules/framework/brpm_script_executor.rb +146 -0
- data/modules/framework/config.yml +7 -0
- data/modules/framework/config/customer_include.rb +26 -0
- data/modules/framework/config/server.yml +3 -0
- data/modules/framework/customer_include_default.rb +25 -0
- data/modules/framework/lib/logging/brpm_logger.rb +39 -0
- data/modules/framework/lib/logging/logger_base.rb +36 -0
- data/modules/framework/lib/logging/simple_logger.rb +27 -0
- data/modules/framework/lib/params/all_params.rb +80 -0
- data/modules/framework/lib/params/integration_settings.rb +27 -0
- data/modules/framework/lib/params/params.rb +172 -0
- data/modules/framework/lib/params/params_base.rb +81 -0
- data/modules/framework/lib/params/request_params.rb +38 -0
- data/modules/framework/lib/resource_framework.rb +211 -0
- data/modules/framework/lib/rest_api.rb +155 -0
- data/modules/framework/lib/semaphore.rb +79 -0
- data/modules/framework/lib/utilities.rb +317 -0
- data/modules/framework/lib/version_control/git.rb +192 -0
- data/modules/framework/lib/version_control/svn.rb +221 -0
- data/modules/framework/log.html +39 -0
- data/modules/framework/tests/all_params_spec.rb +116 -0
- data/modules/framework/tests/brpm_auto_spec.rb +84 -0
- data/modules/framework/tests/customer_include/config/customer_include.rb +10 -0
- data/modules/framework/tests/customer_include/config/server.yml +3 -0
- data/modules/framework/tests/customer_include_spec.rb +29 -0
- data/modules/framework/tests/local_jirb.rb +15 -0
- data/modules/framework/tests/params_spec.rb +172 -0
- data/modules/framework/tests/request_params_spec.rb +86 -0
- data/modules/framework/tests/server_yaml_spec.rb +19 -0
- data/modules/framework/tests/spec_helper.rb +42 -0
- data/modules/framework/transport/dispatch_baa.rb +355 -0
- data/modules/framework/transport/dispatch_base.rb +345 -0
- data/modules/framework/transport/dispatch_nsh.rb +248 -0
- data/modules/framework/transport/dispatch_ssh.rb +154 -0
- data/modules/framework/transport/transport_baa.rb +1095 -0
- data/modules/framework/transport/transport_nsh.rb +359 -0
- data/modules/framework/transport/transport_ssh.rb +220 -0
- data/modules/framework/write_to.rb +1 -0
- data/modules/jenkins/automations/create_release.rb +4 -0
- data/modules/jenkins/automations/create_release.txt +23 -0
- data/modules/jenkins/automations/f2_downloadJenkinsArtifact.rb +126 -0
- data/modules/jenkins/config.yml +7 -0
- data/modules/jenkins/lib/jenkins.rb +300 -0
- data/modules/jenkins/resource_automations/f2_rsc_jenkinsJobs.rb +58 -0
- data/modules/jira/automations/add_comment.rb +4 -0
- data/modules/jira/automations/add_comment.txt +23 -0
- data/modules/jira/automations/create_release.rb +4 -0
- data/modules/jira/automations/create_release.txt +23 -0
- data/modules/jira/automations/delete_release.rb +4 -0
- data/modules/jira/automations/delete_release.txt +23 -0
- data/modules/jira/automations/transition_issue.rb +4 -0
- data/modules/jira/automations/transition_issue.txt +23 -0
- data/modules/jira/automations/transition_issues_for_request.rb +29 -0
- data/modules/jira/automations/transition_issues_for_request.txt +20 -0
- data/modules/jira/automations/transition_issues_for_run.rb +26 -0
- data/modules/jira/automations/transition_issues_for_run.txt +20 -0
- data/modules/jira/automations/update_release.rb +4 -0
- data/modules/jira/automations/update_release.txt +26 -0
- data/modules/jira/config.yml +7 -0
- data/modules/jira/lib/jira_rest_client.rb +185 -0
- data/modules/jira/tests/create_read_update_delete_release_spec.rb +39 -0
- data/modules/jira/tests/spec_helper.rb +39 -0
- data/modules/jira/tests/transition_issue_spec.rb +32 -0
- data/modules/patch_process_management/automations/execute_job/script.rb +105 -0
- data/modules/patch_process_management/automations/execute_job/wrapper.txt +39 -0
- data/modules/patch_process_management/automations/patch_analysis/script.rb +107 -0
- data/modules/patch_process_management/automations/patch_analysis/wrapper.txt +33 -0
- data/modules/patch_process_management/automations/patch_readiness/script.rb +89 -0
- data/modules/patch_process_management/automations/patch_readiness/wrapper.txt +33 -0
- data/modules/patch_process_management/automations/patch_remediation/script.rb +217 -0
- data/modules/patch_process_management/automations/patch_remediation/wrapper.txt +40 -0
- data/modules/patch_process_management/config.yml +10 -0
- data/modules/teamcity/automations/trigger_build.rb +4 -0
- data/modules/teamcity/automations/trigger_build.txt +14 -0
- data/modules/teamcity/config.yml +7 -0
- data/modules/teamcity/lib/teamcity_rest_client.rb +17 -0
- data/modules/teamcity/tests/spec_helper.rb +34 -0
- data/modules/teamcity/tests/trigger_build_spec.rb +27 -0
- data/modules/windows/automations/deploy_directory_over_windows_shares/script.rb +87 -0
- data/modules/windows/automations/deploy_directory_over_windows_shares/wrapper.txt +29 -0
- data/modules/windows/automations/deploy_file_over_windows_shares/script.rb +31 -0
- data/modules/windows/automations/deploy_file_over_windows_shares/wrapper.txt +24 -0
- data/modules/windows/config.yml +6 -0
- data/modules/windows/lib/samba.rb +29 -0
- metadata +397 -0
@@ -0,0 +1,183 @@
|
|
1
|
+
BrpmAuto.require_module "brpm"
|
2
|
+
require_relative "../../jira_mappings"
|
3
|
+
|
4
|
+
def process_event(event)
|
5
|
+
@brpm_rest_client = BrpmRestClient.new("http://#{ENV["EVENT_HANDLER_BRPM_HOST"]}:#{ENV["EVENT_HANDLER_BRPM_PORT"]}/brpm", ENV["EVENT_HANDLER_BRPM_TOKEN"])
|
6
|
+
|
7
|
+
if event.has_key?("request")
|
8
|
+
BrpmAuto.log "The event is for a request #{event["event"][0]}..."
|
9
|
+
process_request_event(event)
|
10
|
+
elsif event.has_key?("run")
|
11
|
+
BrpmAuto.log "The event is for a run #{event["event"][0]}..."
|
12
|
+
process_run_event(event)
|
13
|
+
elsif event.has_key?("plan")
|
14
|
+
BrpmAuto.log "The event is for a plan #{event["event"][0]}..."
|
15
|
+
process_plan_event(event)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def process_request_event(event)
|
20
|
+
if event["event"][0] == "create"
|
21
|
+
request = event["request"].find { |item| item["type"] == "new" }
|
22
|
+
|
23
|
+
BrpmAuto.log "Request '#{request["name"][0]}' created"
|
24
|
+
elsif event["event"][0] == "update"
|
25
|
+
request_old_state = event["request"].find { |item| item["type"] == "old" }
|
26
|
+
request_new_state = event["request"].find { |item| item["type"] == "new" }
|
27
|
+
|
28
|
+
if request_old_state["aasm-state"][0] != request_new_state["aasm-state"][0] or request_new_state["aasm-state"][0] == "complete" #TODO bug when a request is moved to complete the old state is also reported as complete
|
29
|
+
BrpmAuto.log "Request '#{request_new_state["name"][0]}' moved from state '#{request_old_state["aasm-state"][0]}' to state '#{request_new_state["aasm-state"][0]}'"
|
30
|
+
|
31
|
+
if request_new_state["aasm-state"][0] == "planned"
|
32
|
+
process_app_release_event(request_new_state)
|
33
|
+
elsif request_new_state["aasm-state"][0] == "complete"
|
34
|
+
update_tickets_in_jira_by_request(request_new_state)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def process_run_event(event)
|
41
|
+
if event["event"][0] == "create"
|
42
|
+
run = event["run"].find { |item| item["type"] == "new" }
|
43
|
+
|
44
|
+
BrpmAuto.log "Run '#{run["name"][0]}' created"
|
45
|
+
elsif event["event"][0] == "update"
|
46
|
+
run_old_state = event["run"].find { |item| item["type"] == "old" }
|
47
|
+
run_new_state = event["run"].find { |item| item["type"] == "new" }
|
48
|
+
|
49
|
+
if run_old_state["aasm-state"][0] != run_new_state["aasm-state"][0]
|
50
|
+
BrpmAuto.log "Run '#{run_new_state["name"][0]}' moved from state '#{run_old_state["aasm-state"][0]}' to state '#{run_new_state["aasm-state"][0]}'"
|
51
|
+
|
52
|
+
if run_new_state["aasm-state"][0] == "complete"
|
53
|
+
update_tickets_in_jira_by_run(run_new_state)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def process_plan_event(event)
|
60
|
+
if event["event"][0] == "create"
|
61
|
+
plan = event["plan"].find { |item| item["type"] == "new" }
|
62
|
+
|
63
|
+
BrpmAuto.log "Plan '#{plan["name"][0]}' created"
|
64
|
+
|
65
|
+
create_release_in_jira(plan)
|
66
|
+
|
67
|
+
elsif event["event"][0] == "update"
|
68
|
+
plan_old_state = event["plan"].find { |item| item["type"] == "old" }
|
69
|
+
plan_new_state = event["plan"].find { |item| item["type"] == "new" }
|
70
|
+
|
71
|
+
if plan_old_state["aasm-state"][0] != plan_new_state["aasm-state"][0]
|
72
|
+
BrpmAuto.log "Plan '#{plan_new_state["name"][0]}' moved from state '#{plan_old_state["aasm-state"][0]}' to state '#{plan_new_state["aasm-state"][0]}'"
|
73
|
+
end
|
74
|
+
|
75
|
+
if plan_new_state["name"][0].start_with?(plan_old_state["name"][0] + " [deleted ")
|
76
|
+
BrpmAuto.log "Plan '#{plan_old_state["name"][0]}' deleted"
|
77
|
+
|
78
|
+
delete_release_in_jira(plan_old_state)
|
79
|
+
|
80
|
+
elsif plan_old_state["name"][0] != plan_new_state["name"][0]
|
81
|
+
BrpmAuto.log "Plan '#{plan_new_state["name"][0]}' moved from state '#{plan_old_state["aasm-state"][0]}' to state '#{plan_new_state["aasm-state"][0]}'"
|
82
|
+
|
83
|
+
update_release_in_jira(plan_old_state, plan_new_state)
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
#################################
|
90
|
+
# BRPM
|
91
|
+
|
92
|
+
def process_app_release_event(request)
|
93
|
+
release_request_stage_name = "Release"
|
94
|
+
release_request_environment_name = "development"
|
95
|
+
release_request_template_prefix = "Release"
|
96
|
+
deployment_request_stage_name = "Entrance"
|
97
|
+
|
98
|
+
request_with_details = @brpm_rest_client.get_request_by_id(request["id"][0]["content"])
|
99
|
+
if request_with_details.has_key?("plan_member")
|
100
|
+
plan_id = request_with_details["plan_member"]["plan"]["id"]
|
101
|
+
plan_name = request_with_details["plan_member"]["plan"]["name"]
|
102
|
+
stage_name = request_with_details["plan_member"]["stage"]["name"]
|
103
|
+
app_name = request_with_details["apps"][0]["name"]
|
104
|
+
release_request_template_name = "#{release_request_template_prefix} #{app_name} - with promotion"
|
105
|
+
release_request_name = request_with_details["name"].sub("Deploy", "Release")
|
106
|
+
|
107
|
+
if stage_name == deployment_request_stage_name
|
108
|
+
BrpmAuto.log "Creating an app release request for plan '#{plan_name}' and app '#{app_name}' ..."
|
109
|
+
@brpm_rest_client.create_request_for_plan_from_template(plan_id, release_request_stage_name, release_request_template_name, release_request_name, release_request_environment_name, true)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
#################################
|
114
|
+
|
115
|
+
#################################
|
116
|
+
# JIRA
|
117
|
+
|
118
|
+
def get_default_params
|
119
|
+
params = {}
|
120
|
+
params["SS_integration_dns"] = ENV["EVENT_HANDLER_JIRA_URL"]
|
121
|
+
params["SS_integration_username"] = ENV["EVENT_HANDLER_JIRA_USERNAME"]
|
122
|
+
params["SS_integration_password"] = ENV["EVENT_HANDLER_JIRA_PASSWORD"]
|
123
|
+
|
124
|
+
params["brpm_url"] = "http://#{ENV["EVENT_HANDLER_BRPM_HOST"]}:#{ENV["EVENT_HANDLER_BRPM_PORT"]}/brpm"
|
125
|
+
params["brpm_api_token"] = ENV["EVENT_HANDLER_BRPM_TOKEN"]
|
126
|
+
|
127
|
+
params["log_file"] = ENV["EVENT_HANDLER_LOG_FILE"]
|
128
|
+
params
|
129
|
+
end
|
130
|
+
|
131
|
+
def update_tickets_in_jira_by_request(request)
|
132
|
+
params = get_default_params
|
133
|
+
params["request_id"] = request["id"][0]["content"]
|
134
|
+
|
135
|
+
request_with_details = @brpm_rest_client.get_request_by_id(request["id"][0]["content"])
|
136
|
+
if request_with_details.has_key?("plan_member")
|
137
|
+
stage_name = request_with_details["plan_member"]["stage"]["name"]
|
138
|
+
|
139
|
+
BrpmAuto.log "Getting the target JIRA issue status for stage #{stage_name}..."
|
140
|
+
params["target_issue_status"] = map_stage_to_issue_status(stage_name)
|
141
|
+
|
142
|
+
BrpmScriptExecutor.execute_automation_script("jira", "transition_issues_for_request", params)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def update_tickets_in_jira_by_run(run)
|
147
|
+
params = get_default_params
|
148
|
+
params["run_id"] = run["id"][0]["content"]
|
149
|
+
|
150
|
+
BrpmAuto.log "Getting the stage of this run..."
|
151
|
+
stage = @brpm_rest_client.get_plan_stage_by_id(run["plan_stage_id"][0]["content"])
|
152
|
+
|
153
|
+
BrpmAuto.log "Getting the target JIRA issue status for stage #{stage["name"]}..."
|
154
|
+
params["target_issue_status"] = map_stage_to_issue_status(stage["name"])
|
155
|
+
|
156
|
+
BrpmScriptExecutor.execute_automation_script("jira", "transition_issues_for_run", params)
|
157
|
+
end
|
158
|
+
|
159
|
+
def create_release_in_jira(plan)
|
160
|
+
params = get_default_params
|
161
|
+
params["jira_release_field_id"] = ENV["EVENT_HANDLER_JIRA_RELEASE_FIELD_ID"]
|
162
|
+
params["release_name"] = plan["name"][0]
|
163
|
+
|
164
|
+
BrpmScriptExecutor.execute_automation_script("jira", "create_release", params)
|
165
|
+
end
|
166
|
+
|
167
|
+
def update_release_in_jira(old_plan, new_plan)
|
168
|
+
params = get_default_params
|
169
|
+
params["jira_release_field_id"] = ENV["EVENT_HANDLER_JIRA_RELEASE_FIELD_ID"]
|
170
|
+
params["old_release_name"] = old_plan["name"][0]
|
171
|
+
params["new_release_name"] = new_plan["name"][0]
|
172
|
+
|
173
|
+
BrpmScriptExecutor.execute_automation_script("jira", "update_release", params)
|
174
|
+
end
|
175
|
+
|
176
|
+
def delete_release_in_jira(plan)
|
177
|
+
params = get_default_params
|
178
|
+
params["jira_release_field_id"] = ENV["EVENT_HANDLER_JIRA_RELEASE_FIELD_ID"]
|
179
|
+
params["release_name"] = plan["name"][0]
|
180
|
+
|
181
|
+
BrpmScriptExecutor.execute_automation_script("jira", "delete_release", params)
|
182
|
+
end
|
183
|
+
#################################
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require_relative "../spec_helper"
|
2
|
+
|
3
|
+
describe '/api/applications' do
|
4
|
+
before(:all) do
|
5
|
+
setup
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should create an application' do
|
9
|
+
app = {}
|
10
|
+
app["name"] = "rest_api_test_app1"
|
11
|
+
|
12
|
+
result = brpm_post "v1/apps", { :app => app}
|
13
|
+
|
14
|
+
result["code"].should eq(201)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should create another application' do
|
18
|
+
app = {}
|
19
|
+
app["name"] = "rest_api_test_app2"
|
20
|
+
|
21
|
+
result = brpm_post "v1/apps", { :app => app}
|
22
|
+
|
23
|
+
result["code"].should eq(201)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should get all the applications' do
|
27
|
+
result = brpm_get "v1/apps"
|
28
|
+
|
29
|
+
result["code"].should eq(200)
|
30
|
+
result["response"].length.should be >= 6
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should get an application by name' do
|
34
|
+
result = brpm_get "v1/apps?filters[name]=rest_api_test_app1"
|
35
|
+
|
36
|
+
result["code"].should eq(200)
|
37
|
+
result["response"].length.should eq(1)
|
38
|
+
result["response"][0]["name"].should eq("rest_api_test_app1")
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should update an application' do
|
42
|
+
result = brpm_get "v1/apps?filters[name]=rest_api_test_app1"
|
43
|
+
|
44
|
+
result["code"].should eq(200)
|
45
|
+
|
46
|
+
app_id = result["response"][0]["id"]
|
47
|
+
|
48
|
+
newname = "#{Time.now.strftime("%Y%m%d%H%M%S")} - rest_api_test_app1"
|
49
|
+
app = {}
|
50
|
+
app["name"] = newname
|
51
|
+
|
52
|
+
result = brpm_put "v1/apps/#{app_id}", { :app => app}
|
53
|
+
|
54
|
+
result["code"].should eq(202)
|
55
|
+
result["response"]["name"].should eq(newname)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should update another application' do
|
59
|
+
result = brpm_get "v1/apps?filters[name]=rest_api_test_app2"
|
60
|
+
|
61
|
+
result["code"].should eq(200)
|
62
|
+
|
63
|
+
app_id = result["response"][0]["id"]
|
64
|
+
|
65
|
+
newname = "#{Time.now.strftime("%Y%m%d%H%M%S")} - rest_api_test_app2"
|
66
|
+
app = {}
|
67
|
+
app["name"] = newname
|
68
|
+
|
69
|
+
result = brpm_put "v1/apps/#{app_id}", { :app => app}
|
70
|
+
|
71
|
+
result["code"].should eq(202)
|
72
|
+
result["response"]["name"].should eq(newname)
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should delete all applications' do
|
76
|
+
result = brpm_get "v1/apps"
|
77
|
+
|
78
|
+
result["code"].should eq(200)
|
79
|
+
|
80
|
+
result["response"].each do |app|
|
81
|
+
if app["name"] =~ /rest_api_test_app/
|
82
|
+
result = brpm_delete "v1/apps/#{app["id"]}"
|
83
|
+
|
84
|
+
result["code"].should eq(202)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require_relative "../spec_helper"
|
2
|
+
|
3
|
+
plan_id = nil
|
4
|
+
|
5
|
+
describe '/api/plans' do
|
6
|
+
before(:all) do
|
7
|
+
setup
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should _create_ a plan from a plan template with associated stages and request templates' do
|
11
|
+
plan = {}
|
12
|
+
plan["name"] = "#{Time.now.strftime("%Y%m%d%H%M%S")} - rest_api_test_plan_from_template"
|
13
|
+
plan["plan_template_name"] = "rest_api_test_plan_template"
|
14
|
+
plan["deployment_coordinator_id"] = ADMIN_USER_ID
|
15
|
+
plan["environment"] = "aws_cloud"
|
16
|
+
plan["app_ids"] = [SMARTRELEASE_APP_ID]
|
17
|
+
|
18
|
+
result = brpm_post "v1/plans", { :plan => plan}
|
19
|
+
|
20
|
+
result["code"].should eq(201)
|
21
|
+
|
22
|
+
plan_id = result["response"]["id"]
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should _plan_ a plan from a plan template with associated stages and request templates' do
|
26
|
+
plan = {}
|
27
|
+
plan["aasm_event"] = "plan_it"
|
28
|
+
|
29
|
+
result = brpm_put "v1/plans/#{plan_id}", { :plan => plan}
|
30
|
+
|
31
|
+
result["code"].should eq(202)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should _start_ a plan from a plan template with associated stages and request templates' do
|
35
|
+
plan = {}
|
36
|
+
plan["aasm_event"] = "start"
|
37
|
+
|
38
|
+
result = brpm_put "v1/plans/#{plan_id}", { :plan => plan}
|
39
|
+
|
40
|
+
result["code"].should eq(202)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should start all requests from the plan' do
|
44
|
+
result = brpm_get "v1/plans/#{plan_id}"
|
45
|
+
|
46
|
+
result["code"].should eq(200)
|
47
|
+
|
48
|
+
plan = result["response"]
|
49
|
+
plan["members"].each do |member|
|
50
|
+
if member.has_key?("request")
|
51
|
+
request_id = member["request"]["number"].to_i - 1000
|
52
|
+
|
53
|
+
request_data = {}
|
54
|
+
request_data["aasm_event"] = "plan_it"
|
55
|
+
|
56
|
+
result = brpm_put "v1/requests/#{request_id}", { :request => request_data}
|
57
|
+
|
58
|
+
result["code"].should eq(202)
|
59
|
+
|
60
|
+
request_data = {}
|
61
|
+
request_data["aasm_event"] = "start"
|
62
|
+
|
63
|
+
result = brpm_put "v1/requests/#{request_id}", { :request => request_data}
|
64
|
+
|
65
|
+
result["code"].should eq(202)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require_relative "../spec_helper"
|
2
|
+
|
3
|
+
request_id = nil
|
4
|
+
|
5
|
+
describe '/api/requests' do
|
6
|
+
before(:all) do
|
7
|
+
setup
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should create a request' do
|
11
|
+
request = {}
|
12
|
+
request["name"] = "rest_api_test_request"
|
13
|
+
request["requestor_id"] = ADMIN_USER_ID
|
14
|
+
request["deployment_coordinator_id"] = ADMIN_USER_ID
|
15
|
+
request["environment"] = "aws_cloud"
|
16
|
+
request["app_ids"] = [SMARTRELEASE_APP_ID]
|
17
|
+
|
18
|
+
result = brpm_post "v1/requests", { :request => request}
|
19
|
+
|
20
|
+
result["code"].should eq(201)
|
21
|
+
|
22
|
+
request_id = result["response"]["id"]
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should plan a request' do
|
26
|
+
request = {}
|
27
|
+
request["aasm_event"] = "plan_it"
|
28
|
+
|
29
|
+
result = brpm_put "v1/requests/#{request_id}", { :request => request}
|
30
|
+
|
31
|
+
result["code"].should eq(202)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should start a request' do
|
35
|
+
request = {}
|
36
|
+
request["aasm_event"] = "start"
|
37
|
+
|
38
|
+
result = brpm_put "v1/requests/#{request_id}", { :request => request}
|
39
|
+
|
40
|
+
result["code"].should eq(202)
|
41
|
+
end
|
42
|
+
|
43
|
+
# it 'should get all the requests' do
|
44
|
+
# result = brpm_get "v1/requests"
|
45
|
+
#
|
46
|
+
# result["code"].should eq(200)
|
47
|
+
# result["response"].length.should be >= 1
|
48
|
+
# end
|
49
|
+
|
50
|
+
it 'should get a request by name' do
|
51
|
+
result = brpm_get "v1/requests?filters[name]=rest_api_test_request"
|
52
|
+
|
53
|
+
result["code"].should eq(200)
|
54
|
+
result["response"].length.should be >= 1
|
55
|
+
result["response"][0]["name"].should eq("rest_api_test_request")
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative "../../../../../modules/framework/brpm_auto"
|
2
|
+
|
3
|
+
ADMIN_USER_ID = 1
|
4
|
+
SMARTRELEASE_APP_ID = 1
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@brpm_url = "http://#{ENV["BRPM_HOST"]}:#{ENV["BRPM_PORT"]}/brpm"
|
8
|
+
@brpm_api_token = ENV["BRPM_API_TOKEN"]
|
9
|
+
|
10
|
+
BrpmAuto.setup( { "output_dir" => "/home/jenkins" } )
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_token(path)
|
14
|
+
path + (path.include?("?") ? "&" : "?") + "token=#{@brpm_api_token}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def brpm_get(path, options = {})
|
18
|
+
Rest.get("#{@brpm_url}/#{add_token(path)}", options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def brpm_post(path, data, options = {})
|
22
|
+
Rest.post("#{@brpm_url}/#{add_token(path)}", data, options)
|
23
|
+
end
|
24
|
+
|
25
|
+
def brpm_put(path, data, options = {})
|
26
|
+
Rest.put("#{@brpm_url}/#{add_token(path)}", data, options)
|
27
|
+
end
|
28
|
+
|
29
|
+
def brpm_delete(path, options = {})
|
30
|
+
Rest.delete("#{@brpm_url}/#{add_token(path)}", options)
|
31
|
+
end
|
32
|
+
|
33
|
+
setup
|
@@ -0,0 +1,33 @@
|
|
1
|
+
BrpmAuto.require_module "brpm"
|
2
|
+
require_relative "../../jira_mappings"
|
3
|
+
|
4
|
+
def process_event(event)
|
5
|
+
BrpmAuto.log "Processing event #{event["id"]} ..."
|
6
|
+
|
7
|
+
@brpm_rest_client = BrpmRestClient.new("http://#{ENV["WEBHOOK_RECEIVER_BRPM_HOST"]}:#{ENV["WEBHOOK_RECEIVER_BRPM_PORT"]}/brpm", ENV["WEBHOOK_RECEIVER_BRPM_TOKEN"])
|
8
|
+
|
9
|
+
issue = event["issue"]
|
10
|
+
|
11
|
+
BrpmAuto.log "Validating the issue..."
|
12
|
+
unless is_issue_valid(issue)
|
13
|
+
raise "Validation error, see the log file for more information."
|
14
|
+
end
|
15
|
+
|
16
|
+
# Prepare the ticket placeholder we will use to create or update the ticket
|
17
|
+
ticket = {}
|
18
|
+
ticket["project_server_id"] = ENV["WEBHOOK_RECEIVER_INTEGRATION_ID"]
|
19
|
+
|
20
|
+
BrpmAuto.log "Associating the ticket with a plan..."
|
21
|
+
if issue["fields"]["customfield_#{ENV["WEBHOOK_RECEIVER_JIRA_RELEASE_FIELD_ID"]}"]
|
22
|
+
plan = @brpm_rest_client.get_plan_by_name(issue["fields"]["customfield_#{ENV["WEBHOOK_RECEIVER_JIRA_RELEASE_FIELD_ID"]}"]["value"])
|
23
|
+
ticket["plan_ids"] = [ plan["id"] ] unless plan.nil?
|
24
|
+
end
|
25
|
+
|
26
|
+
BrpmAuto.log "Mapping the issue to the ticket..."
|
27
|
+
map_issue_to_ticket(issue, ticket)
|
28
|
+
|
29
|
+
BrpmAuto.log "Creating or updating the ticket..."
|
30
|
+
@brpm_rest_client.create_or_update_ticket(ticket)
|
31
|
+
|
32
|
+
BrpmAuto.log "Finished processing the event."
|
33
|
+
end
|