Method: Fastlane::Actions::MakeChangelogFromJenkinsAction.run

Defined in:
fastlane/lib/fastlane/actions/make_changelog_from_jenkins.rb

.run(params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'fastlane/lib/fastlane/actions/make_changelog_from_jenkins.rb', line 8

def self.run(params)
  require 'json'
  require 'net/http'

  changelog = ""

  if Helper.ci? || Helper.test?
    # The "BUILD_URL" environment variable is set automatically by Jenkins in every build
    jenkins_api_url = URI(ENV["BUILD_URL"] + "api/json\?wrapper\=changes\&xpath\=//changeSet//comment")
    begin
      json = JSON.parse(Net::HTTP.get(jenkins_api_url))
      json['changeSet']['items'].each do |item|
        comment = params[:include_commit_body] ? item['comment'] : item['msg']
        changelog << comment.strip + "\n"
      end
    rescue => ex
      UI.error("Unable to read/parse changelog from jenkins: #{ex.message}")
    end
  end

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