Sha256: 9a86eb9348bf14f634054a3e242c153a1dcaf08a5cf3023ce09673e3253a7062

Contents?: true

Size: 1.55 KB

Versions: 6

Compression:

Stored size: 1.55 KB

Contents

module Gitlab
  module QA
    module Component
      class Jira
        include Scenario::Actable

        JIRA_IMAGE = 'registry.gitlab.com/gitlab-org/gitlab-qa/jira-gitlab'.freeze
        JIRA_IMAGE_TAG = '8.8-project-and-issue'.freeze

        attr_reader :docker
        attr_accessor :environment, :network
        attr_writer :name

        def initialize
          @docker = Docker::Engine.new
          @environment = {}
        end

        def name
          @name ||= "jira"
        end

        def hostname
          "#{name}.#{network}"
        end

        def instance
          raise 'Please provide a block!' unless block_given?

          prepare
          start

          yield self
        ensure
          teardown
        end

        def prepare
          @docker.pull(JIRA_IMAGE, JIRA_IMAGE_TAG)

          return if @docker.network_exists?(network)

          @docker.network_create(network)
        end

        def start
          docker.run(JIRA_IMAGE, JIRA_IMAGE_TAG) do |command|
            command << '-d '
            command << "--name #{name}"
            command << "--net #{network}"
            command << "--hostname #{hostname}"
            command << "--publish 8080:8080"
          end
        end

        def restart
          @docker.restart(name)
        end

        def teardown
          raise 'Invalid instance name!' unless name

          @docker.stop(name)
          @docker.remove(name)
        end

        def set_jira_hostname
          ::Gitlab::QA::Runtime::Env.jira_hostname = hostname
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gitlab-qa-5.13.6 lib/gitlab/qa/component/jira.rb
gitlab-qa-5.13.3 lib/gitlab/qa/component/jira.rb
gitlab-qa-5.13.2 lib/gitlab/qa/component/jira.rb
gitlab-qa-5.13.1 lib/gitlab/qa/component/jira.rb
gitlab-qa-5.13.0 lib/gitlab/qa/component/jira.rb
gitlab-qa-5.12.0 lib/gitlab/qa/component/jira.rb