Sha256: 05f80555a93de8d1fe272c3c1a6196b0fcd25e8f39927d86fc30ac2b71db1446

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

module CiToolkit
  # Bitrise constants
  class BitriseEnv
    attr_reader :build_number, :build_url,
                :pull_request_number,
                :app_url,
                :git_branch

    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"],
      git_branch: ENV["BITRISE_GIT_BRANCH"]
    })
      @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]
      @git_branch = options[:git_branch]
    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

1 entries across 1 versions & 1 rubygems

Version Path
ci_toolkit-1.0.19 lib/ci_toolkit/bitrise_env.rb