forked from SiarheiFedartsou/fastlane-plugin-versioning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci_build_number_spec.rb
203 lines (145 loc) · 5.83 KB
/
ci_build_number_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
require 'spec_helper'
require 'webmock/rspec'
describe Fastlane::Actions::CiBuildNumberAction do
describe "ci_build_number" do
it "Returns build number defined in BUILD_NUMBER environment variable if running on Jenkins" do
ENV['JENKINS_HOME'] = "Users/user/hudson/workspace"
ENV['BUILD_NUMBER'] = '42'
result = Fastlane::FastFile.new.parse("lane :test do
ci_build_number
end").runner.execute(:test)
expect(result).to eq('42')
ENV.delete('JENKINS_HOME')
ENV.delete('BUILD_NUMBER')
end
it "Returns build number defined in TRAVIS_BUILD_NUMBER environment variable if running on Travis CI" do
ENV['TRAVIS'] = '1'
ENV['TRAVIS_BUILD_NUMBER'] = '42'
result = Fastlane::FastFile.new.parse("lane :test do
ci_build_number
end").runner.execute(:test)
expect(result).to eq('42')
ENV.delete('TRAVIS')
ENV.delete('TRAVIS_BUILD_NUMBER')
end
it "Returns build number defined in CIRCLE_BUILD_NUM environment variable if running on Circle CI" do
ENV['CIRCLECI'] = '1'
ENV['CIRCLE_BUILD_NUM'] = '42'
result = Fastlane::FastFile.new.parse("lane :test do
ci_build_number
end").runner.execute(:test)
expect(result).to eq('42')
ENV.delete('CIRCLECI')
ENV.delete('CIRCLE_BUILD_NUM')
end
it "Returns build number defined in BUILD_NUMBER environment variable if running on TeamCity" do
ENV['TEAMCITY_VERSION'] = '1.0'
ENV['BUILD_NUMBER'] = '42'
result = Fastlane::FastFile.new.parse("lane :test do
ci_build_number
end").runner.execute(:test)
expect(result).to eq('42')
ENV.delete('TEAMCITY_VERSION')
ENV.delete('BUILD_NUMBER')
end
it "Returns build number defined in GO_PIPELINE_COUNTER environment variable if running on GoCD" do
ENV['GO_PIPELINE_NAME'] = 'Job'
ENV['GO_PIPELINE_COUNTER'] = '42'
result = Fastlane::FastFile.new.parse("lane :test do
ci_build_number
end").runner.execute(:test)
expect(result).to eq('42')
ENV.delete('GO_PIPELINE_NAME')
ENV.delete('GO_PIPELINE_COUNTER')
end
it "Returns build number defined in bamboo_buildNumber environment variable if running on Bamboo" do
ENV['bamboo_buildKey'] = 'JOB'
ENV['bamboo_buildNumber'] = '42'
result = Fastlane::FastFile.new.parse("lane :test do
ci_build_number
end").runner.execute(:test)
expect(result).to eq('42')
ENV.delete('bamboo_buildKey')
ENV.delete('bamboo_buildNumber')
end
it "Returns build number defined in CI_JOB_ID environment variable if running on GitLab CI < v11.0 " do
ENV['GITLAB_CI'] = '1'
ENV['CI_JOB_ID'] = '42'
result = Fastlane::FastFile.new.parse("lane :test do
ci_build_number
end").runner.execute(:test)
expect(result).to eq('42')
ENV.delete('GITLAB_CI')
ENV.delete('CI_JOB_ID')
end
it "Returns build number defined in CI_PIPELINE_IID environment variable if running on GitLab CI >= v11.0" do
ENV['GITLAB_CI'] = '1'
ENV['CI_PIPELINE_IID'] = '44'
ENV['CI_JOB_ID'] = '42'
result = Fastlane::FastFile.new.parse("lane :test do
ci_build_number
end").runner.execute(:test)
expect(result).to_not eq('42')
expect(result).to eq('44')
ENV.delete('GITLAB_CI')
ENV.delete('CI_JOB_ID')
ENV.delete('CI_PIPELINE_IID')
end
it "Returns build number defined in XCS_INTEGRATION_NUMBER environment variable if running on Xcode Server" do
ENV['XCS'] = '1'
ENV['XCS_INTEGRATION_NUMBER'] = '42'
result = Fastlane::FastFile.new.parse("lane :test do
ci_build_number
end").runner.execute(:test)
expect(result).to eq('42')
ENV.delete('XCS')
ENV.delete('XCS_INTEGRATION_NUMBER')
end
it "Returns build number defined in BITBUCKET_BUILD_NUMBER environment variable if running on Bitbucket Pipelines" do
ENV['BITBUCKET_BUILD_NUMBER'] = '42'
result = Fastlane::FastFile.new.parse("lane :test do
ci_build_number
end").runner.execute(:test)
expect(result).to eq('42')
ENV.delete('BITBUCKET_BUILD_NUMBER')
end
it "Returns build number defined in BITRISE_BUILD_NUMBER environment variable if running on Bitrise" do
ENV['BITRISE_BUILD_NUMBER'] = '42'
result = Fastlane::FastFile.new.parse("lane :test do
ci_build_number
end").runner.execute(:test)
expect(result).to eq('42')
ENV.delete('BITRISE_BUILD_NUMBER')
end
it "Returns build number defined in BUDDYBUILD_BUILD_NUMBER environment variable if running on BuddyBuild" do
ENV['BUDDYBUILD_BUILD_NUMBER'] = '42'
result = Fastlane::FastFile.new.parse("lane :test do
ci_build_number
end").runner.execute(:test)
expect(result).to eq('42')
ENV.delete('BUDDYBUILD_BUILD_NUMBER')
end
it "Returns build number defined in APPVEYOR_BUILD_NUMBER environment variable if running on AppVeyor" do
ENV['APPVEYOR_BUILD_NUMBER'] = '42'
result = Fastlane::FastFile.new.parse("lane :test do
ci_build_number
end").runner.execute(:test)
expect(result).to eq('42')
ENV.delete('APPVEYOR_BUILD_NUMBER')
end
it "Returns build number defined in GITHUB_RUN_NUMBER environment variable if running on Github Actions" do
ENV['GITHUB_RUN_NUMBER'] = '42'
result = Fastlane::FastFile.new.parse("lane :test do
ci_build_number
end").runner.execute(:test)
expect(result).to eq('42')
ENV.delete('GITHUB_RUN_NUMBER')
end
it "Uses 1 as a default build number if cannot detect" do
result = Fastlane::FastFile.new.parse("lane :test do
ci_build_number
end").runner.execute(:test)
expect(result).to eq('1')
end
end
end