Sha256: cc1e8bb504cc7968146f3f2b4305143fe461bde856020e2861bc238b88b5fe54

Contents?: true

Size: 1.11 KB

Versions: 23

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

# https://docs.semaphoreci.com/article/12-environment-variables
module KnapsackPro
  module Config
    module CI
      class Semaphore2 < Base
        def node_total
          ENV['SEMAPHORE_JOB_COUNT']
        end

        def node_index
          index = ENV['SEMAPHORE_JOB_INDEX']
          index.to_i - 1 if index
        end

        def node_build_id
          ENV['SEMAPHORE_WORKFLOW_ID']
        end

        def commit_hash
          ENV['SEMAPHORE_GIT_SHA']
        end

        def branch
          ENV['SEMAPHORE_GIT_BRANCH']
        end

        def project_dir
          if ENV['HOME'] && ENV['SEMAPHORE_GIT_DIR']
            "#{ENV['HOME']}/#{ENV['SEMAPHORE_GIT_DIR']}"
          end
        end

        def user_seat
          # not provided
        end

        def detected
          # check 2 keys to be sure we are using Semaphore 2.0
          ENV.key?('SEMAPHORE') && ENV.key?('SEMAPHORE_WORKFLOW_ID') ? self.class : nil
        end

        def fixed_queue_split
          false
        end

        def ci_provider
          "Semaphore CI 2.0"
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
knapsack_pro-7.13.0 lib/knapsack_pro/config/ci/semaphore2.rb
knapsack_pro-7.12.1 lib/knapsack_pro/config/ci/semaphore2.rb
knapsack_pro-7.12.0 lib/knapsack_pro/config/ci/semaphore2.rb
knapsack_pro-7.11.0 lib/knapsack_pro/config/ci/semaphore2.rb
knapsack_pro-7.10.0 lib/knapsack_pro/config/ci/semaphore2.rb
knapsack_pro-7.9.0 lib/knapsack_pro/config/ci/semaphore2.rb
knapsack_pro-7.8.2 lib/knapsack_pro/config/ci/semaphore2.rb
knapsack_pro-7.8.1 lib/knapsack_pro/config/ci/semaphore2.rb
knapsack_pro-7.8.0 lib/knapsack_pro/config/ci/semaphore2.rb
knapsack_pro-7.7.0 lib/knapsack_pro/config/ci/semaphore2.rb
knapsack_pro-7.6.2 lib/knapsack_pro/config/ci/semaphore2.rb
knapsack_pro-7.6.1 lib/knapsack_pro/config/ci/semaphore2.rb
knapsack_pro-7.6.0 lib/knapsack_pro/config/ci/semaphore2.rb
knapsack_pro-7.1.0 lib/knapsack_pro/config/ci/semaphore2.rb
knapsack_pro-7.0.1 lib/knapsack_pro/config/ci/semaphore2.rb
knapsack_pro-7.0.0 lib/knapsack_pro/config/ci/semaphore2.rb
knapsack_pro-6.0.4 lib/knapsack_pro/config/ci/semaphore2.rb
knapsack_pro-6.0.3 lib/knapsack_pro/config/ci/semaphore2.rb
knapsack_pro-6.0.2 lib/knapsack_pro/config/ci/semaphore2.rb
knapsack_pro-6.0.1 lib/knapsack_pro/config/ci/semaphore2.rb