Sha256: b395902a43a7333c6aa9bad002e84211e5302276859b1c2686419fc8a5d67ce3

Contents?: true

Size: 1.62 KB

Versions: 12

Compression:

Stored size: 1.62 KB

Contents

# frozen_string_literal: true

module CiToolkit
  # Bitrise constants
  # noinspection RubyTooManyInstanceVariablesInspection
  class BitriseEnv
    attr_reader :build_number, :build_url,
                :pull_request_number,
                :app_url,
                :git_branch,
                :app_slug,
                :git_commit,
                :repository_slug

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

    def build_from_pr?
      !pull_request_number.nil?
    end

    def build_from_cron_job?
      @build_from_cron_job
    end

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ci_toolkit-1.5.22 lib/ci_toolkit/bitrise_env.rb
ci_toolkit-1.5.21 lib/ci_toolkit/bitrise_env.rb
ci_toolkit-1.5.20 lib/ci_toolkit/bitrise_env.rb
ci_toolkit-1.5.19 lib/ci_toolkit/bitrise_env.rb
ci_toolkit-1.5.17 lib/ci_toolkit/bitrise_env.rb
ci_toolkit-1.5.16 lib/ci_toolkit/bitrise_env.rb
ci_toolkit-1.5.15 lib/ci_toolkit/bitrise_env.rb
ci_toolkit-1.5.14 lib/ci_toolkit/bitrise_env.rb
ci_toolkit-1.5.13 lib/ci_toolkit/bitrise_env.rb
ci_toolkit-1.5.12 lib/ci_toolkit/bitrise_env.rb
ci_toolkit-1.5.11 lib/ci_toolkit/bitrise_env.rb
ci_toolkit-1.5.10 lib/ci_toolkit/bitrise_env.rb