Class: CiToolkit::BitriseEnv

Inherits:
Object
  • Object
show all
Defined in:
lib/ci_toolkit/bitrise_env.rb

Overview

Bitrise constants noinspection RubyTooManyInstanceVariablesInspection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = { build_number: ENV.fetch("BITRISE_BUILD_NUMBER", nil), build_url: ENV.fetch("BITRISE_BUILD_URL", nil), pull_request_number: ENV.fetch("BITRISE_PULL_REQUEST", nil), build_from_cron_job: !ENV["BITRISE_SCHEDULED_BUILD"].nil?, repository_owner: ENV["BITRISEIO_GIT_REPOSITORY_OWNER"] || "crvshlab", repository_slug: ENV.fetch("BITRISEIO_GIT_REPOSITORY_SLUG", nil), app_url: ENV.fetch("BITRISE_APP_URL", nil), app_slug: ENV.fetch("BITRISE_APP_SLUG", nil), git_branch: ENV.fetch("BITRISE_GIT_BRANCH", nil), git_commit: ENV.fetch("BITRISE_GIT_COMMIT", nil), api_token: ENV.fetch("BITRISE_TOKEN", nil) }) ⇒ BitriseEnv

Returns a new instance of BitriseEnv.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ci_toolkit/bitrise_env.rb', line 15

def initialize(options = {
  build_number: ENV.fetch("BITRISE_BUILD_NUMBER", nil),
  build_url: ENV.fetch("BITRISE_BUILD_URL", nil),
  pull_request_number: ENV.fetch("BITRISE_PULL_REQUEST", nil),
  build_from_cron_job: !ENV["BITRISE_SCHEDULED_BUILD"].nil?,
  repository_owner: ENV["BITRISEIO_GIT_REPOSITORY_OWNER"] || "crvshlab",
  repository_slug: ENV.fetch("BITRISEIO_GIT_REPOSITORY_SLUG", nil),
  app_url: ENV.fetch("BITRISE_APP_URL", nil),
  app_slug: ENV.fetch("BITRISE_APP_SLUG", nil),
  git_branch: ENV.fetch("BITRISE_GIT_BRANCH", nil),
  git_commit: ENV.fetch("BITRISE_GIT_COMMIT", nil),
  api_token: ENV.fetch("BITRISE_TOKEN", nil)
})
  @build_number = options[:build_number]
  @build_url = options[:build_url]
  @pull_request_number = options[:pull_request_number]
  @build_from_cron_job = options[:build_from_cron_job]
  @repository_owner = options[:repository_owner]
  @repository_slug = options[:repository_slug]
  @app_url = options[:app_url]
  @app_slug = options[:app_slug]
  @git_branch = options[:git_branch]
  @git_commit = options[:git_commit]
end

Instance Attribute Details

#app_slugObject (readonly)

Returns the value of attribute app_slug.



7
8
9
# File 'lib/ci_toolkit/bitrise_env.rb', line 7

def app_slug
  @app_slug
end

#app_urlObject (readonly)

Returns the value of attribute app_url.



7
8
9
# File 'lib/ci_toolkit/bitrise_env.rb', line 7

def app_url
  @app_url
end

#build_numberObject (readonly)

Returns the value of attribute build_number.



7
8
9
# File 'lib/ci_toolkit/bitrise_env.rb', line 7

def build_number
  @build_number
end

#build_urlObject (readonly)

Returns the value of attribute build_url.



7
8
9
# File 'lib/ci_toolkit/bitrise_env.rb', line 7

def build_url
  @build_url
end

#git_branchObject (readonly)

Returns the value of attribute git_branch.



7
8
9
# File 'lib/ci_toolkit/bitrise_env.rb', line 7

def git_branch
  @git_branch
end

#git_commitObject (readonly)

Returns the value of attribute git_commit.



7
8
9
# File 'lib/ci_toolkit/bitrise_env.rb', line 7

def git_commit
  @git_commit
end

#pull_request_numberObject (readonly)

Returns the value of attribute pull_request_number.



7
8
9
# File 'lib/ci_toolkit/bitrise_env.rb', line 7

def pull_request_number
  @pull_request_number
end

#repository_slugObject (readonly)

Returns the value of attribute repository_slug.



7
8
9
# File 'lib/ci_toolkit/bitrise_env.rb', line 7

def repository_slug
  @repository_slug
end

Instance Method Details

#build_from_cron_job?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/ci_toolkit/bitrise_env.rb', line 44

def build_from_cron_job?
  @build_from_cron_job
end

#build_from_pr?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/ci_toolkit/bitrise_env.rb', line 40

def build_from_pr?
  !pull_request_number.nil?
end

#repository_pathObject



48
49
50
# File 'lib/ci_toolkit/bitrise_env.rb', line 48

def repository_path
  "#{@repository_owner}/#{@repository_slug}"
end