Class: HybridPlatformsConductor::HpcPlugins::Test::JenkinsCiMastersOk
- Defined in:
- lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_masters_ok.rb
Overview
Check that all repositories have a successful master branch on a Jenkins CI
Constant Summary collapse
- SUCCESS_STATUSES =
[ # Add nil as the status of a currently running job (which is always the case for hybrid-platforms) is null nil, # Add ABORTED as it is impossible to make Groovy Pipelines return SUCCESS when we want to abort it normally. 'ABORTED', 'SUCCESS' ]
Constants included from LoggerHelpers
LoggerHelpers::LEVELS_MODIFIERS, LoggerHelpers::LEVELS_TO_STDERR
Instance Attribute Summary
Attributes inherited from Test
#errors, #expected_failure, #name, #node, #platform
Instance Method Summary collapse
-
#test ⇒ Object
Check my_test_plugin.rb.sample documentation for signature details.
Methods inherited from Test
#assert_equal, #assert_match, #error, #executed, #executed?, #initialize, only_on_nodes, only_on_platforms, #to_s
Methods inherited from Plugin
extend_config_dsl_with, #initialize, valid?
Methods included from LoggerHelpers
#err, #init_loggers, #log_component=, #log_debug?, #log_level=, #out, #section, #set_loggers_format, #stderr_device, #stderr_device=, #stderr_displayed?, #stdout_device, #stdout_device=, #stdout_displayed?, #stdouts_to_s, #with_progress_bar
Constructor Details
This class inherits a constructor from HybridPlatformsConductor::Test
Instance Method Details
#test ⇒ Object
Check my_test_plugin.rb.sample documentation for signature details.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_masters_ok.rb', line 25 def test @config.for_each_bitbucket_repo do |_bitbucket, repo_info| if repo_info[:jenkins_ci_url].nil? error "Repository #{repo_info[:name]} does not have any Jenkins CI URL configured." else master_info_url = "#{repo_info[:jenkins_ci_url]}/job/master/api/json" Credentials.with_credentials_for(:jenkins_ci, @logger, @logger_stderr, url: master_info_url) do |jenkins_user, jenkins_password| begin # Get the master branch info from the API master_info = JSON.parse(open(master_info_url, http_basic_authentication: [jenkins_user, jenkins_password]).read) # Get the last build's URL last_build_info_url = "#{master_info['lastBuild']['url']}/api/json" last_build_info = JSON.parse(open(last_build_info_url, http_basic_authentication: [jenkins_user, jenkins_password]).read) log_debug "Build info for #{master_info_url}:\n#{JSON.pretty_generate(last_build_info)}" error "Last build for job #{repo_info[:project]}/#{repo_info[:name]} is in status #{last_build_info['result']}: #{master_info['lastBuild']['url']}" unless SUCCESS_STATUSES.include?(last_build_info['result']) rescue error "Error while checking Jenkins CI job for #{repo_info[:project]}/#{repo_info[:name]} from URL #{master_info_url}: #{$!}" end end end end end |