Class: Fastlane::Actions::CiBuildNumberAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/versioning/actions/ci_build_number.rb

Class Method Summary collapse

Class Method Details

.authorsObject



69
70
71
# File 'lib/fastlane/plugin/versioning/actions/ci_build_number.rb', line 69

def self.authors
  ["Siarhei Fedartsou", "John Douglas"]
end

.categoryObject



79
80
81
# File 'lib/fastlane/plugin/versioning/actions/ci_build_number.rb', line 79

def self.category
  :building
end

.descriptionObject



61
62
63
# File 'lib/fastlane/plugin/versioning/actions/ci_build_number.rb', line 61

def self.description
  "Detects current build number defined by CI system"
end

.example_codeObject



73
74
75
76
77
# File 'lib/fastlane/plugin/versioning/actions/ci_build_number.rb', line 73

def self.example_code
  [
    'ci_build_number'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/fastlane/plugin/versioning/actions/ci_build_number.rb', line 65

def self.is_supported?(platform)
  true
end

.run(params) ⇒ Object



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
# File 'lib/fastlane/plugin/versioning/actions/ci_build_number.rb', line 4

def self.run(params)
  if ENV.key?('JENKINS_HOME') || ENV.key?('JENKINS_URL')
    return ENV['BUILD_NUMBER']
  end

  if ENV.key?('TRAVIS')
    return ENV['TRAVIS_BUILD_NUMBER']
  end

  if ENV.key?('CIRCLECI')
    return ENV['CIRCLE_BUILD_NUM']
  end

  if ENV.key?('TEAMCITY_VERSION')
    return ENV['BUILD_NUMBER']
  end

  if ENV.key?('GO_PIPELINE_NAME')
    return ENV['GO_PIPELINE_COUNTER']
  end

  if ENV.key?('bamboo_buildKey')
    return ENV['bamboo_buildNumber']
  end

  if ENV.key?('GITLAB_CI')
    return ENV['CI_PIPELINE_IID'] || ENV['CI_JOB_ID']
  end

  if ENV.key?('XCS')
    return ENV['XCS_INTEGRATION_NUMBER']
  end

  if ENV.key?('BITBUCKET_BUILD_NUMBER')
    return ENV['BITBUCKET_BUILD_NUMBER']
  end

  if ENV.key?('BITRISE_BUILD_NUMBER')
    return ENV['BITRISE_BUILD_NUMBER']
  end

  if ENV.key?('BUDDYBUILD_BUILD_NUMBER')
    return ENV['BUDDYBUILD_BUILD_NUMBER']
  end

  if ENV.key?('APPVEYOR_BUILD_NUMBER')
    return ENV['APPVEYOR_BUILD_NUMBER']
  end

  if ENV.key?('GITHUB_RUN_NUMBER')
    return ENV['GITHUB_RUN_NUMBER']
  end

  UI.error("Cannot detect current CI build number. Defaulting to \"1\".")
  "1"
end