fastlane-plugin-ci_changelog 0.5.1 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1afc08216b7c1b0b4bbd439069efc88f16854ca7
4
- data.tar.gz: da33a8b256d212e7d2690b94817655eef240a822
2
+ SHA256:
3
+ metadata.gz: 6929c151e19d4d869c4420cb5d0416cf9dfa597b5a46cd0ecd98719b1270b564
4
+ data.tar.gz: de27968b1da6d06eac4e0df8440982f180bdeb4e3f51fa1ab443e0c21e9e512b
5
5
  SHA512:
6
- metadata.gz: 5f5c2df844bafb1efee0eec3aff52d2e2741081a60ce6d508217f82eb0d4c29f653f973479430e37337ab9612fee154ae47be506ec40da8d2b0ed2454960f53a
7
- data.tar.gz: 4b9ffa290c9a82d186892f7f5ba05d7268b6af153c2118a2d3c0815cefdd674c73029d0ffc655cf48edb2aa14984b2fdbe043e4041b2068bab508950370a97d3
6
+ metadata.gz: f427a4c1e91bb112d469e7d78727e840149a527655e9483dfe5861618e654b392339c0c3ef4349aabce7f93c043e9e6b5ef401fcc29ba7a310c187169c821ed9
7
+ data.tar.gz: f6f956dc9b13b175869f3cabb88bfa94ffac97cfca3396faf94e627840ff47ea7f836f494dc84a04c1941353037fa5cdc52fbbaa020a79bf02c117664a4bf356
data/README.md CHANGED
@@ -12,7 +12,7 @@ fastlane add_plugin ci_changelog
12
12
 
13
13
  ## About ci_changelog
14
14
 
15
- Automate generate changelog between previous and the latest commit of scm during the ci system
15
+ Automate generate changelog between previous and the latest commit of SCM during the CI services.
16
16
 
17
17
  ### Available CI system:
18
18
 
@@ -22,7 +22,7 @@ Automate generate changelog between previous and the latest commit of scm during
22
22
 
23
23
  ## Configuration
24
24
 
25
- ```
25
+ ```text
26
26
  $ fastlane action ci_changelog
27
27
  +------------------------------+---------+--------------+
28
28
  | Used plugins |
@@ -68,7 +68,6 @@ Loading documentation for ci_changelog:
68
68
  | CICL_CHANGELOG | the json formatted changelog of CI (datetime, message, author and email) |
69
69
  +----------------+--------------------------------------------------------------------------+
70
70
  Access the output values using `lane_context[SharedValues::VARIABLE_NAME]`
71
-
72
71
  ```
73
72
 
74
73
  ## Example
@@ -71,12 +71,13 @@ module Fastlane
71
71
  end
72
72
 
73
73
  def self.fetch_jenkins_changelog!
74
- commits = []
74
+ changelog = []
75
75
 
76
+ build_branch = ENV['GIT_BRANCH']
76
77
  build_number = ENV['BUILD_NUMBER'].to_i
77
78
  loop do
78
79
  begin
79
- build_url = "#{ENV['JOB_URL']}/#{build_number}/api/json"
80
+ build_url = "#{ENV['JOB_URL']}#{build_number}/api/json"
80
81
  res =
81
82
  if Helper::CiChangelogHelper.determine_jenkins_basic_auth?
82
83
  HTTP.basic_auth(user: @params.fetch(:jenkins_user), pass: @params.fetch(:jenkins_token))
@@ -86,15 +87,21 @@ module Fastlane
86
87
  end
87
88
 
88
89
  if res.code == 200
89
- build_status, data = Helper::CiChangelogHelper.dump_jenkin_commits(res.body)
90
- commits.concat(data)
90
+ build_status, data = Helper::CiChangelogHelper.dump_jenkins_commits(res.body, build_branch)
91
+ UI.verbose("Fetching changelog #{build_url}")
92
+ UI.verbose("- Branch #{build_branch}")
93
+ UI.verbose("- Status #{build_status}")
94
+ UI.verbose("- Changelog #{data}")
95
+
96
+ changelog.concat(data) unless data.empty?
97
+
91
98
  break if build_status == true
92
99
  end
93
100
 
94
101
  build_number -= 1
95
102
 
96
103
  break if build_number <= 0
97
- rescue
104
+ rescue HTTP::Error
98
105
  # NOTE: break out of loop if build setted keep max builds count
99
106
  break
100
107
  end
@@ -103,7 +110,7 @@ module Fastlane
103
110
  # NOTE: Auto detect the range changelog of build fail.
104
111
  # commits = Helper::CiChangelogHelper.git_commits(ENV['GIT_PREVIOUS_SUCCESSFUL_COMMIT']) if Helper.is_test? && commits.empty?
105
112
 
106
- Helper::CiChangelogHelper.store_sharedvalue(SharedValues::CICL_CHANGELOG, commits.to_json)
113
+ Helper::CiChangelogHelper.store_sharedvalue(SharedValues::CICL_CHANGELOG, changelog.to_json)
107
114
  end
108
115
 
109
116
  def self.fetch_jenkins_env!
@@ -128,6 +135,9 @@ module Fastlane
128
135
 
129
136
  if res.code == 200
130
137
  build_status, data = Helper::CiChangelogHelper.dump_gitlab_commits(res.body)
138
+ UI.verbose("Fetching changelog #{build_url}")
139
+ UI.verbose("- Status #{build_status}")
140
+ UI.verbose("- Changelog #{data}")
131
141
 
132
142
  if build_status == true
133
143
  commits = data if commits.empty?
@@ -12,10 +12,15 @@ module Fastlane
12
12
  git_logs.split("\n")
13
13
  end
14
14
 
15
- def self.dump_jenkin_commits(body)
15
+ def self.dump_jenkins_commits(body, branch)
16
16
  json = JSON.parse(body)
17
+ result = json['result'] == 'SUCCESS' ? true : false
18
+
19
+ # return if previous build do not equal to current build branch.
20
+ return [result, []] unless jenkins_use_same_branch?(json, branch)
21
+
17
22
  # TODO: It must use reverse_each to correct the changelog
18
- commit = json['changeSet']['items'].each_with_object([]) do |item, obj|
23
+ commits = json['changeSet']['items'].each_with_object([]) do |item, obj|
19
24
  obj.push({
20
25
  id: item['commitId'],
21
26
  date: item['date'],
@@ -26,11 +31,7 @@ module Fastlane
26
31
  })
27
32
  end
28
33
 
29
- if json['result'] == 'SUCCESS'
30
- [true, commit]
31
- else
32
- [false, commit]
33
- end
34
+ [result, commits]
34
35
  end
35
36
 
36
37
  def self.dump_gitlab_commits(body)
@@ -79,6 +80,19 @@ module Fastlane
79
80
  return true
80
81
  end
81
82
 
83
+ def self.jenkins_use_same_branch?(json, name)
84
+ same_branch = false
85
+ json['actions'].each do |item|
86
+ if revision = item['lastBuiltRevision']
87
+ revision['branch'].each do |branch|
88
+ same_branch = true if branch['name'].end_with?(name)
89
+ end
90
+ end
91
+ end
92
+
93
+ same_branch
94
+ end
95
+
82
96
  def self.store_sharedvalue(key, value)
83
97
  Actions.lane_context[key] = value
84
98
  ENV[key.to_s] = value
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module CiChangelog
3
- VERSION = '0.5.1'.freeze
3
+ VERSION = '0.5.5'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-ci_changelog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - icyleaf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-26 00:00:00.000000000 Z
11
+ date: 2019-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -139,8 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  - !ruby/object:Gem::Version
140
140
  version: '0'
141
141
  requirements: []
142
- rubyforge_project:
143
- rubygems_version: 2.6.12
142
+ rubygems_version: 3.0.3
144
143
  signing_key:
145
144
  specification_version: 4
146
145
  summary: Automate generate changelog between previous build failed and the latest