Class: Fastlane::Actions::MakeChangelogFromJenkinsAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/make_changelog_from_jenkins.rb

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, return_value, sh, step_text

Class Method Details

.authorsObject



44
45
46
# File 'lib/fastlane/actions/make_changelog_from_jenkins.rb', line 44

def self.authors
  ["mandrizzle"]
end

.available_optionsObject



31
32
33
34
35
36
37
38
# File 'lib/fastlane/actions/make_changelog_from_jenkins.rb', line 31

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :fallback_changelog,
                                 description: "Fallback changelog if there is not one on Jenkins",
                                 optional: true,
                                 default_value: "")
  ]
end

.descriptionObject



23
24
25
# File 'lib/fastlane/actions/make_changelog_from_jenkins.rb', line 23

def self.description
  "Generate a changelog using the Changes section from the current Jenkins build"
end

.detailsObject



27
28
29
# File 'lib/fastlane/actions/make_changelog_from_jenkins.rb', line 27

def self.details
  "This is useful when deploying automated builds. The changelog from Jenkins lists all the commit messages since the last build."
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/fastlane/actions/make_changelog_from_jenkins.rb', line 48

def self.is_supported?(platform)
  true
end

.outputObject



40
41
42
# File 'lib/fastlane/actions/make_changelog_from_jenkins.rb', line 40

def self.output
  ['FL_CHANGELOG', 'The changelog generated by Jenkins']
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fastlane/actions/make_changelog_from_jenkins.rb', line 4

def self.run(params)
  Actions.verify_gem!('nokogiri')
  require 'nokogiri'
  require 'net/http'

  changelog = ""

  if Helper.is_ci?
    # The "BUILD_URL" environment variable is set automatically by Jenkins in every build
    jenkins_xml_url = URI(ENV["BUILD_URL"] + "api/xml\?wrapper\=changes\&xpath\=//changeSet//comment")
    doc = Nokogiri.XML(Net::HTTP.get(jenkins_xml_url))
    doc.css('comment').each do |comment|
      changelog << comment.text.strip + "\n"
    end
  end

  Actions.lane_context[SharedValues::FL_CHANGELOG] = changelog.strip.length > 0 ? changelog : params[:fallback_changelog]
end