Class: Hookie::Plugin::JenkinsPlugin
- Inherits:
-
BasePlugin
- Object
- BasePlugin
- Hookie::Plugin::JenkinsPlugin
- Defined in:
- lib/hookie/plugins/jenkins_plugin.rb
Instance Attribute Summary
Attributes inherited from BasePlugin
Instance Method Summary collapse
Methods inherited from BasePlugin
#config_key, #initialize, #log, #to_s
Constructor Details
This class inherits a constructor from Hookie::BasePlugin
Instance Method Details
#post_receive ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/hookie/plugins/jenkins_plugin.rb', line 27 def post_receive uri = URI.parse(config[:url]) http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Get.new(uri.request_uri) if config[:auth] request.basic_auth(*config[:auth].split(":")) end response = http.request(request) log "Response: #{response.body}" end |
#should_run? ⇒ Boolean
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/hookie/plugins/jenkins_plugin.rb', line 7 def should_run? #puts "Config: #{config}" unless config[:url] log "Jenkins URL not configured!" return false end if config[:branches] allowed_branches = config[:branches].split(",") commits = @framework.changes.map { |change| change[:commit] } branches = commits.collect { |commit| @framework.head_names_for_commit(commit) } branches.flatten! if (branches & allowed_branches).empty? log "No commits on matching branches (#{allowed_branches.join(', ')})" return false end end return true end |