Sha256: d971bc25a4d6bad0f54bfa457898c22ed0cadd8a92d5640e2161e36749624d7a

Contents?: true

Size: 1.62 KB

Versions: 6

Compression:

Stored size: 1.62 KB

Contents

module Fastlane
  module Actions
    class MakeChangelogFromJenkinsAction < Action
      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

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

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

      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

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

      def self.authors
        ["mandrizzle"]
      end

      def self.is_supported?(platform)
        true
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fastlane-1.61.0 lib/fastlane/actions/make_changelog_from_jenkins.rb
fastlane-1.60.0 lib/fastlane/actions/make_changelog_from_jenkins.rb
fastlane-1.59.0 lib/fastlane/actions/make_changelog_from_jenkins.rb
fastlane-1.58.0 lib/fastlane/actions/make_changelog_from_jenkins.rb
fastlane-1.57.0 lib/fastlane/actions/make_changelog_from_jenkins.rb
fastlane-1.56.0 lib/fastlane/actions/make_changelog_from_jenkins.rb