brpm_content 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 @@
|
|
|
1
|
+
write_to(File.read(BrpmAuto.logger.step_run_log_file_path))
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
params = BrpmAuto.params
|
|
2
|
+
|
|
3
|
+
BrpmAuto.log "Creating a new option for plan '#{params["release_name"]}' in the JIRA dropdown custom field with id #{params["jira_release_field_id"]}..."
|
|
4
|
+
JiraRestClient.new.create_option_for_dropdown_custom_field(params["jira_release_field_id"], params["release_name"])
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
###
|
|
2
|
+
# jira_release_field_id:
|
|
3
|
+
# name: JIRA release field id
|
|
4
|
+
# required: yes
|
|
5
|
+
# release_name:
|
|
6
|
+
# name: Release name
|
|
7
|
+
# required: yes
|
|
8
|
+
###
|
|
9
|
+
|
|
10
|
+
#=== BMC Application Automation Integration Server: JIRA ===#
|
|
11
|
+
# [integration_id=4]
|
|
12
|
+
#=== End ===#
|
|
13
|
+
|
|
14
|
+
require "#{params["SS_script_support_path"]}/git_repos/brpm_content/modules/framework/brpm_script_executor.rb"
|
|
15
|
+
|
|
16
|
+
params["direct_execute"] = "true"
|
|
17
|
+
|
|
18
|
+
params["SS_integration_dns"] = SS_integration_dns
|
|
19
|
+
params["SS_integration_username"] = SS_integration_username
|
|
20
|
+
params["SS_integration_password_enc"] = SS_integration_password_enc
|
|
21
|
+
params["SS_integration_details"] = YAML.load(SS_integration_details)
|
|
22
|
+
|
|
23
|
+
BrpmScriptExecutor.execute_automation_script("jira", "create_release", params)
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Description: Download an artifact from jenkins
|
|
2
|
+
# Instructions: Modify this automation for each flavor of application deployment
|
|
3
|
+
# add any arguments you want to be available to other steps here by prefixing them with "ARG_"
|
|
4
|
+
#=> About the f2 framework: upon loading the automation, several utility classes will be available
|
|
5
|
+
# @rpm: the BrpmAutomation class, @p: the Param class, @rest: the BrpmRest class and
|
|
6
|
+
# @transport: the Transport class - the transport class will be loaded dependent on the SS_transport property value (ssh, nsh or baa)
|
|
7
|
+
#---------------------- f2_getRequestInputs_basic -----------------------#
|
|
8
|
+
# Description: Enter Request inputs for component deploy and promotion
|
|
9
|
+
# Author(s): 2015 Brady Byrd
|
|
10
|
+
#---------------------- Arguments --------------------------#
|
|
11
|
+
###
|
|
12
|
+
# Jenkins Artifact:
|
|
13
|
+
# name: Artifact to download from Jenkins
|
|
14
|
+
# type: in-text
|
|
15
|
+
# position: A1:D1
|
|
16
|
+
# required: no
|
|
17
|
+
# Jenkins Project:
|
|
18
|
+
# name: Jenkins Project
|
|
19
|
+
# type: in-external-single-select
|
|
20
|
+
# external_resource: f2_rsc_jenkinsJobs
|
|
21
|
+
# position: A2:D2
|
|
22
|
+
# required: no
|
|
23
|
+
# Jenkins Build No:
|
|
24
|
+
# name: Build number from Jenkins
|
|
25
|
+
# type: in-text
|
|
26
|
+
# position: A3:C3
|
|
27
|
+
# required: no
|
|
28
|
+
###
|
|
29
|
+
|
|
30
|
+
#=== General Integration Server: DevOps_Jenkins ===#
|
|
31
|
+
# [integration_id=2]
|
|
32
|
+
SS_integration_dns = "http://vw-aus-rem-dv11.bmc.com:8080"
|
|
33
|
+
SS_integration_username = "bbyrd"
|
|
34
|
+
SS_integration_password = "-private-"
|
|
35
|
+
SS_integration_details = ""
|
|
36
|
+
SS_integration_password_enc = "__SS__Cj1Jek1QTjBaTkYyUQ=="
|
|
37
|
+
#=== End ===#
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
#---------------------- Declarations -----------------------#
|
|
41
|
+
params["direct_execute"] = true #Set for local execution
|
|
42
|
+
#require 'C:/BMC/persist/automation_libs/brpm_framework.rb'
|
|
43
|
+
require "#{FRAMEWORK_DIR}/brpm_framework.rb"
|
|
44
|
+
rpm_load_module "jenkins"
|
|
45
|
+
|
|
46
|
+
#---------------------- Methods ----------------------------#
|
|
47
|
+
# Assign local variables to properties and script arguments
|
|
48
|
+
def logical_list_value(arg_value, match_value)
|
|
49
|
+
result = nil
|
|
50
|
+
items = [arg_value]
|
|
51
|
+
return !(match_value =~ /#{arg_value}.*/).nil? unless arg_value =~ /(\sor\s|\sand\s|\,)/
|
|
52
|
+
list_items = arg_value.split(" or ") if arg_value.include?(" or ")
|
|
53
|
+
list_items = arg_value.split(" and ") if arg_value.include?(" and ")
|
|
54
|
+
list_items = arg_value.split(",") if arg_value.include?(",")
|
|
55
|
+
list_items.map{|l| l.strip }.each{|k|
|
|
56
|
+
result = (match_value =~ /#{k}.*/)
|
|
57
|
+
break if !result.nil?
|
|
58
|
+
}
|
|
59
|
+
!result.nil?
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
#---------------------- Variables --------------------------#
|
|
63
|
+
# Assign local variables to properties and script arguments
|
|
64
|
+
ARG_PREFIX = "ARG_"
|
|
65
|
+
jenkins_project = @p.get("Jenkins Project", @p.jenkins_project)
|
|
66
|
+
jenkins_build_no = @p.get("Jenkins Build No", @p.jenkins_build_no) #if passed from rest
|
|
67
|
+
jenkins_build_no = "lastSuccessfulBuild" if jenkins_build_no == ""
|
|
68
|
+
jenkins_artifact_value = @p.required("Jenkins Artifact")
|
|
69
|
+
package_name = "jenkins_#{jenkins_build_no}"
|
|
70
|
+
staging_dir = @rpm.get_staging_dir(package_name, true)
|
|
71
|
+
win_curl = @p.win_curl #"C:\\bmc\\curl.exe"
|
|
72
|
+
download_file = ""
|
|
73
|
+
transfer_properties = {}
|
|
74
|
+
|
|
75
|
+
#---------------------- Main Body --------------------------#
|
|
76
|
+
# Set a property in General for each component to deploy
|
|
77
|
+
@rpm.message_box "Artifacts from Jenkins Build", "title"
|
|
78
|
+
@rpm.log "Jenkins:\n\tServer: #{SS_integration_dns}\n\tJob: #{jenkins_project}\n\tBuildNo: #{jenkins_build_no}\n\tArtifact: #{jenkins_artifact_value}"
|
|
79
|
+
@jenkins = Jenkins.new(SS_integration_dns, script_params, {"username" => SS_integration_username, "password" => decrypt_string_with_prefix(SS_integration_password_enc), "job_name" => jenkins_project})
|
|
80
|
+
cur_server = @p.get_server_list.keys.first
|
|
81
|
+
raise "No server selected" if cur_server.length < 3
|
|
82
|
+
channel_root = @p.get_server_property(cur_server, "CHANNEL_ROOT")
|
|
83
|
+
channel_root = "C:\\temp" if channel_root == ""
|
|
84
|
+
|
|
85
|
+
rest_result = @jenkins.job_build_data(jenkins_build_no)
|
|
86
|
+
build_number = rest_result["data"]["number"]
|
|
87
|
+
@rpm.log "Artifacts from Build #{build_number}:"
|
|
88
|
+
found = false
|
|
89
|
+
rest_result["data"]["artifacts"].each do |item|
|
|
90
|
+
@rpm.log("\t#{item["fileName"]} => #{item["relativePath"]}")
|
|
91
|
+
if logical_list_value(jenkins_artifact_value, item["fileName"])
|
|
92
|
+
found = true
|
|
93
|
+
download_file = item["fileName"]
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
raise "ERROR artifact not in list: #{jenkins_artifact}" unless found
|
|
97
|
+
@rpm.log "Full Build Results:"
|
|
98
|
+
@rpm.log rest_result["data"].inspect
|
|
99
|
+
new_name = "Regression - #{jenkins_project} - #{build_number}"
|
|
100
|
+
res = @rest.update("requests", (@p.request_id.to_i - 1000).to_s, {"request" => {"name" => new_name}})
|
|
101
|
+
|
|
102
|
+
# New Method out of mem errors trying to download
|
|
103
|
+
if false #<100mb files only
|
|
104
|
+
@rpm.log "Downloading file: #{download_file} to #{staging_dir}"
|
|
105
|
+
@jenkins.get_build_artifact(jenkins_build_no, download_file, staging_dir)
|
|
106
|
+
package_info = @nsh.package_staged_artifacts(staging_dir, "#{package_name}.zip")
|
|
107
|
+
else
|
|
108
|
+
@rpm.log "Downloading #{download_file} from Jenkins on target"
|
|
109
|
+
# http://vw-aus-rem-dv11.bmc.com:8080/job/Trunk_BRPM_INSTALLERS/356/artifact/BRPM_Windows_201505220925.zip
|
|
110
|
+
url_part = "#{jenkins_build_no}/artifact/#{download_file}"
|
|
111
|
+
url = File.join(SS_integration_dns,"job",jenkins_project, url_part)
|
|
112
|
+
target_os = @rpm.get_server_list.first[1]["os_platform"]
|
|
113
|
+
cmd = "#{win_curl} -X GET #{url} > #{channel_root}\\#{download_file}"
|
|
114
|
+
@rpm.log "Command: #{cmd}"
|
|
115
|
+
script_file = @transport.make_temp_file(cmd, "windows")
|
|
116
|
+
result = @transport.execute_script(script_file, {"transfer_properties" => transfer_properties})
|
|
117
|
+
@rpm.log "cURL Output: #{result}"
|
|
118
|
+
package_info = {"instance_path" => File.join(channel_root, download_file)}
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
@p.assign_local_param("jenkins_build_no", build_number)
|
|
122
|
+
@p.assign_local_param("instance_#{@p.SS_component}", package_info)
|
|
123
|
+
@p.assign_local_param("jenkins_download_package", download_file)
|
|
124
|
+
@p.save_local_params # Cleanup and save
|
|
125
|
+
|
|
126
|
+
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
require 'uri'
|
|
2
|
+
require 'net/http'
|
|
3
|
+
|
|
4
|
+
# Base class for working with Subversion
|
|
5
|
+
class Jenkins
|
|
6
|
+
|
|
7
|
+
# Initializes an instance of the class
|
|
8
|
+
#
|
|
9
|
+
# ==== Attributes
|
|
10
|
+
#
|
|
11
|
+
# * +url+ - url for Jenkins server...
|
|
12
|
+
# * +params+ - params hash
|
|
13
|
+
# * +options+ - hash of options includes:...
|
|
14
|
+
# job_name - jenkins job name (from url)...
|
|
15
|
+
# username - jenkins user username...
|
|
16
|
+
# password - jenkins user password...
|
|
17
|
+
# verbose - true for verbose output (default = false)...
|
|
18
|
+
# simulate - simulate command - echo it (default = false)...
|
|
19
|
+
#
|
|
20
|
+
def initialize(url, options, compat_options = {})
|
|
21
|
+
self.extend Utilities
|
|
22
|
+
if options.has_key?("SS_output_dir")
|
|
23
|
+
BrpmAuto.log "Load for this class has changed, no longer necessary to send params as 2nd argument"
|
|
24
|
+
options = compat_options
|
|
25
|
+
end
|
|
26
|
+
@url = url
|
|
27
|
+
@username = get_option(options,"username")
|
|
28
|
+
@password = get_option(options,"password")
|
|
29
|
+
@job_name = get_option(options,"job_name")
|
|
30
|
+
@verbose = get_option(options,"verbose", false)
|
|
31
|
+
@simulate = get_option(options,"simulate", false)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Calls the jenkins server via rest
|
|
35
|
+
# Uses the current project and auth information
|
|
36
|
+
# ==== Attributes
|
|
37
|
+
# * +options+ - a hash of options, includes:
|
|
38
|
+
# url_part - the fragment of the url past the project ex.
|
|
39
|
+
# for this url: http://vw-aus-rem-dv11.bmc.com:8080/job/BRPM_4.6-D_WAR/231/api/json
|
|
40
|
+
# the fragment is "231/api/json"
|
|
41
|
+
# username - override existing username
|
|
42
|
+
# password - override existing password
|
|
43
|
+
# method - get/post, defaults to get
|
|
44
|
+
#
|
|
45
|
+
# ==== Returns
|
|
46
|
+
#
|
|
47
|
+
# * +rest_result+ - hash of information including status (success-failure) and data - the rest result
|
|
48
|
+
#
|
|
49
|
+
def jenkins_rest_call(url_part, options = {})
|
|
50
|
+
result = {"status" => "Failure"}
|
|
51
|
+
options["username"] = @username unless options.has_key?("username")
|
|
52
|
+
options["password"] = @password unless options.has_key?("password")
|
|
53
|
+
method = get_option(options,"method") == "post" ? "post" : "get"
|
|
54
|
+
url = File.join(@url,"job",@job_name, url_part)
|
|
55
|
+
BrpmAuto.log "Full url [#{method}]: #{url}" if @simulate || @verbose
|
|
56
|
+
unless @simulate
|
|
57
|
+
response = rest_call(url, method, options)
|
|
58
|
+
BrpmAuto.log "Response: #{response.inspect}" if @verbose
|
|
59
|
+
result["data"] = "#{response["status"]}: #{response["message"]}" unless response["status"] == "success"
|
|
60
|
+
result["data"] = response["data"] if response["status"] == "success"
|
|
61
|
+
result["status"] = response["status"]
|
|
62
|
+
else
|
|
63
|
+
result["status"] = "simulate"
|
|
64
|
+
end
|
|
65
|
+
result
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def set_job_name(new_name)
|
|
69
|
+
@job_name = new_name
|
|
70
|
+
new_name
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Returns the array of Build Jobs
|
|
74
|
+
#
|
|
75
|
+
# ==== Returns
|
|
76
|
+
#
|
|
77
|
+
# * +job_list+ - an array of hashes with job information
|
|
78
|
+
#
|
|
79
|
+
def job_list
|
|
80
|
+
options = {"username" => @username, "password" => @password}
|
|
81
|
+
response = rest_call("#{@url}/api/json", "get", options)
|
|
82
|
+
return "ERROR" if response["status"] == "ERROR"
|
|
83
|
+
response["data"]
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Returns the data of a Build Job
|
|
87
|
+
#
|
|
88
|
+
# ==== Returns
|
|
89
|
+
#
|
|
90
|
+
# * +job_data+ - a hash of job information
|
|
91
|
+
#
|
|
92
|
+
def job_data
|
|
93
|
+
jenkins_rest_call("/api/json")
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Returns the data of a build
|
|
97
|
+
# ==== Attributes
|
|
98
|
+
#
|
|
99
|
+
# * +build_no+ - the id of a build (omit for latest build)
|
|
100
|
+
#
|
|
101
|
+
# ==== Returns
|
|
102
|
+
#
|
|
103
|
+
# * +job_data+ - a hash of job information
|
|
104
|
+
#
|
|
105
|
+
def job_build_data(build_no = nil)
|
|
106
|
+
build_no = "lastBuild" if build_no.nil?
|
|
107
|
+
jenkins_rest_call("#{build_no}/api/json")
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Returns the status of a build
|
|
111
|
+
# ==== Attributes
|
|
112
|
+
#
|
|
113
|
+
# * +build_no+ - the id of a build (omit for latest build)
|
|
114
|
+
#
|
|
115
|
+
# ==== Returns
|
|
116
|
+
#
|
|
117
|
+
# * +hash+ - still_building (ture/false) and status (success/fail)
|
|
118
|
+
#
|
|
119
|
+
def build_status(build_no = nil)
|
|
120
|
+
response = job_build_data(build_no)
|
|
121
|
+
# Now parse for the status and build id
|
|
122
|
+
#log "Raw Result: #{response.inspect}"
|
|
123
|
+
ans = {}
|
|
124
|
+
ans["still_building"] = response["data"]["building"]
|
|
125
|
+
ans["success"] = response["status"]
|
|
126
|
+
ans
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Returns the raw results of a build
|
|
130
|
+
# ==== Attributes
|
|
131
|
+
#
|
|
132
|
+
# * +build_no+ - the id of a build (omit for latest build)
|
|
133
|
+
# * +get_link+ - returns a link to the results instead (optional - default = false)
|
|
134
|
+
#
|
|
135
|
+
# ==== Returns
|
|
136
|
+
#
|
|
137
|
+
# * +job_data+ - text of build output
|
|
138
|
+
#
|
|
139
|
+
def build_results(build_no, get_link = false)
|
|
140
|
+
url_part = "#{build_no}/consoleText"
|
|
141
|
+
if get_link
|
|
142
|
+
response = File.join(@url,"job",@job_name, url_part)
|
|
143
|
+
else
|
|
144
|
+
response = jenkins_rest_call(url_part, {"headers" => {}})
|
|
145
|
+
end
|
|
146
|
+
response
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Monitors a running build
|
|
150
|
+
# ==== Attributes
|
|
151
|
+
#
|
|
152
|
+
# * +build_no+ - the id of a build (omit for latest build)
|
|
153
|
+
#
|
|
154
|
+
# ==== Returns
|
|
155
|
+
#
|
|
156
|
+
# * +job_data+ - a hash of job information
|
|
157
|
+
#
|
|
158
|
+
def monitor_build(build_no)
|
|
159
|
+
# start with an initial build result
|
|
160
|
+
# Now parse for the status and build id
|
|
161
|
+
max_time = MaxBuildTime
|
|
162
|
+
sleep_interval = 15
|
|
163
|
+
result = build_status(build_no)
|
|
164
|
+
results = "Initial test: Build Number: #{build_no}, Status - building: #{result["still_building"].to_s}, result: #{result["success"]}\n"
|
|
165
|
+
# Now Check to see if the token matches
|
|
166
|
+
build_match = true
|
|
167
|
+
#build_match = response.include?(ss_token) if use_token_match # Enable this if using token matching
|
|
168
|
+
BrpmAuto.message_box "Monitoring Build Progress (id: #{build_no})"
|
|
169
|
+
if build_no.to_i > 0 && result["still_building"] == true && build_match
|
|
170
|
+
start_time = Time.now
|
|
171
|
+
elapsed = 0
|
|
172
|
+
complete = false
|
|
173
|
+
until elapsed > (max_time * 60) do
|
|
174
|
+
result = build_status(build_no)
|
|
175
|
+
results += "Status - building: #{result["still_building"].to_s}, result: #{result["success"]}\n"
|
|
176
|
+
if result["still_building"] == false
|
|
177
|
+
BrpmAuto.log "Success - #{result["success"]}"
|
|
178
|
+
complete = true if result["success"] == "SUCCESS"
|
|
179
|
+
complete = false if result["success"] != "SUCCESS"
|
|
180
|
+
break
|
|
181
|
+
else
|
|
182
|
+
elapsed = Time.now - start_time
|
|
183
|
+
BrpmAuto.log "Still building ...elapsed: #{elapsed.to_i.to_s}, pausing for #{sleep_interval.to_s} seconds"
|
|
184
|
+
sleep sleep_interval
|
|
185
|
+
end
|
|
186
|
+
elapsed = Time.now - start_time
|
|
187
|
+
end
|
|
188
|
+
elsif result["success"] != "SUCCESS"
|
|
189
|
+
BrpmAuto.log "Build failed on initial parameters, either could not retrieve build id or token did not match output"
|
|
190
|
+
complete = false
|
|
191
|
+
else
|
|
192
|
+
BrpmAuto.log "Build Successful"
|
|
193
|
+
complete = true
|
|
194
|
+
end
|
|
195
|
+
complete
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# Performs a build on the active project
|
|
199
|
+
# ==== Attributes
|
|
200
|
+
#
|
|
201
|
+
# * +build_arguments+ - a hash of the build arguments
|
|
202
|
+
#
|
|
203
|
+
# ==== Returns
|
|
204
|
+
#
|
|
205
|
+
# * +job_data+ - a hash of job information
|
|
206
|
+
#
|
|
207
|
+
def build(build_arguments = {})
|
|
208
|
+
# Fetch the next build number
|
|
209
|
+
build_details = job_data
|
|
210
|
+
next_build = build_details["data"]["nextBuildNumber"]
|
|
211
|
+
url_part = "build"
|
|
212
|
+
options = {"method" => post, "data" => build_arguments}
|
|
213
|
+
reponse = jenkins_rest_call(url_part, options)
|
|
214
|
+
last_build = next_build
|
|
215
|
+
result = "Web server response: " + response["header"]
|
|
216
|
+
BrpmAuto.log result
|
|
217
|
+
unless response["header"].include?("HTTPFound 302") #response["status"] == "failure"
|
|
218
|
+
BrpmAuto.log "Command_Failed: Build did not launch"
|
|
219
|
+
return -1
|
|
220
|
+
end
|
|
221
|
+
launched = false
|
|
222
|
+
10.times do
|
|
223
|
+
test_result = job_build_data(last_build)
|
|
224
|
+
if test_result["data"].is_a?(String) && test_result["data"].include?("failure")
|
|
225
|
+
BrpmAuto.log "Job not ready waiting..."
|
|
226
|
+
sleep(6)
|
|
227
|
+
else
|
|
228
|
+
launched = true
|
|
229
|
+
break
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
if launched
|
|
233
|
+
return last_build
|
|
234
|
+
else
|
|
235
|
+
BrpmAuto.log "Command_Failed: Build did not launch in 60 seconds"
|
|
236
|
+
return -1
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
# Returns the status of a build
|
|
242
|
+
# ==== Attributes
|
|
243
|
+
#
|
|
244
|
+
# * +build_no+ - jenkins build id
|
|
245
|
+
# * +artifact_name+ - name from the build artifacts list in job data
|
|
246
|
+
# * +target_path+ - folder to download to (default is SS_output_dir)
|
|
247
|
+
#
|
|
248
|
+
# ==== Returns
|
|
249
|
+
#
|
|
250
|
+
# * +status+ - success or failure
|
|
251
|
+
#
|
|
252
|
+
def get_build_artifact(build_no, artifact_name, target_path = nil)
|
|
253
|
+
# http://vw-aus-rem-dv11.bmc.com:8080/job/BRPM_4.6-D_WAR/lastSuccessfulBuild/artifact/brpm_231.war
|
|
254
|
+
url_part = "#{build_no}/artifact/#{artifact_name}"
|
|
255
|
+
url = File.join(@url,"job",@job_name, url_part)
|
|
256
|
+
target_path = @params["SS_output_dir"] if target_path.nil?
|
|
257
|
+
fetch_artifact(url, target_path)
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
private
|
|
261
|
+
|
|
262
|
+
def download_file(artifact_url, download_path)
|
|
263
|
+
package_name = artifact_url.split("/").last
|
|
264
|
+
uri = URI(artifact_url)
|
|
265
|
+
Dir.chdir(download_path)
|
|
266
|
+
Net::HTTP.start(uri.host, uri.port) do |http|
|
|
267
|
+
request = Net::HTTP::Get.new uri.request_uri
|
|
268
|
+
BrpmAuto.log "Downloading: #{artifact_url} to #{download_path}"
|
|
269
|
+
fil = open(package_name, "wb")
|
|
270
|
+
begin
|
|
271
|
+
http.request_get(uri.request_uri) do |resp|
|
|
272
|
+
resp.read_body do |segment|
|
|
273
|
+
fil.write(segment)
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
ensure
|
|
277
|
+
fil.close()
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
"Downloaded to: #{download_path}"
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
def fetch_artifact(url, download_path)
|
|
284
|
+
_response = Net::HTTP.get_response( URI.parse( url ) )
|
|
285
|
+
package_name = url.split("/").last
|
|
286
|
+
case _response
|
|
287
|
+
when Net::HTTPSuccess then
|
|
288
|
+
response = download_file(url, download_path)
|
|
289
|
+
_response
|
|
290
|
+
when Net::HTTPRedirection then
|
|
291
|
+
location = _response['location']
|
|
292
|
+
BrpmAuto.log "\tRedirected to #{location}"
|
|
293
|
+
response = download_file(location, download_path)
|
|
294
|
+
_response
|
|
295
|
+
else
|
|
296
|
+
_response.value
|
|
297
|
+
end
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
end
|