Class: JenkinsTracker::Base
- Inherits:
-
Object
- Object
- JenkinsTracker::Base
- Defined in:
- lib/jenkins_tracker/base.rb
Instance Attribute Summary collapse
-
#build_url ⇒ Object
readonly
include Util.
-
#changelog ⇒ Object
readonly
include Util.
-
#job_name ⇒ Object
readonly
include Util.
-
#tracker_client ⇒ Object
readonly
include Util.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #integrate_job_with_tracker(project_id) ⇒ Object
- #parse_changelog ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/jenkins_tracker/base.rb', line 7 def initialize( = {}) raise FileNotFoundError, "Changelog file not found at: #{[:changelog_file]}" unless File.file?([:changelog_file]) @changelog = File.read([:changelog_file]) @tracker_client = TrackerClient.new(:token => [:tracker_token]) @tracker_client.use_ssl = true @job_name = [:job_name] @build_url = [:build_url] end |
Instance Attribute Details
#build_url ⇒ Object (readonly)
include Util
5 6 7 |
# File 'lib/jenkins_tracker/base.rb', line 5 def build_url @build_url end |
#changelog ⇒ Object (readonly)
include Util
5 6 7 |
# File 'lib/jenkins_tracker/base.rb', line 5 def changelog @changelog end |
#job_name ⇒ Object (readonly)
include Util
5 6 7 |
# File 'lib/jenkins_tracker/base.rb', line 5 def job_name @job_name end |
#tracker_client ⇒ Object (readonly)
include Util
5 6 7 |
# File 'lib/jenkins_tracker/base.rb', line 5 def tracker_client @tracker_client end |
Instance Method Details
#integrate_job_with_tracker(project_id) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/jenkins_tracker/base.rb', line 19 def integrate_job_with_tracker(project_id) parse_changelog.each do |change| note = "*#{change.}* integrated in *#{job_name}* (#{build_url})" tracker_client.add_note_to_story(project_id, change.story_id, note) end end |
#parse_changelog ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/jenkins_tracker/base.rb', line 26 def parse_changelog results = [] changelog.scan(/(\[[#a-zA-Z0-9\s]+\])(.*)/) do |ids, msg| parse_tracker_story_ids(ids).each do |id| results << ChangelogItem.new(:story_id => id, :commit_message => "#{ids}#{msg}".strip) end end results.uniq end |