Sha256: b8776d0fd10807c55fde3cf37788072199c77c778f9a54f7cd31c16ed3e84892

Contents?: true

Size: 1.57 KB

Versions: 27

Compression:

Stored size: 1.57 KB

Contents

module Docman
  class NexusProvider < Docman::Command

    register_command :nexus_provider

    def validate_command
      raise "Please provide 'context'" if @context.nil?
      raise "Context should be of type 'Info'" unless @context.is_a? Docman::Info
      raise "Please provide 'artifact_aid'" if @context['artifact_aid'].nil?
      raise "Please provide 'artifact_gid'" if @context['artifact_gid'].nil?
      raise "Please provide 'artifact_version'" if @context['artifact_version'].nil?
    end

    def execute
      # TODO: refactor it.
      nexus_address = '138.68.81.158:8081'
      a = @context['artifact_aid']
      g = @context['artifact_gid']
      v = @context['artifact_version']
      r = 'releases'
      e = 'tar.gz'
      artifact_file = "#{a}-#{v}.#{e}"

      @context['version_type'] = 'nexus_artifact'
      @context['version'] = v

      FileUtils.mkdir_p(self['target_path'])
      Dir.chdir self['target_path']

      # TODO: refactor cmd execution.
      cmd = "wget -O #{artifact_file} \"http://#{nexus_address}/nexus/service/local/artifact/maven/content?a=#{a}&g=#{g}&v=#{v}&r=#{r}&e=#{e}\""

      `#{cmd}`

      if $?.exitstatus > 0
        raise "Artifact retrieving has been failed: #{cmd}"
      end

      cmd ="tar --strip-components=1 -xzf #{artifact_file}"
      `#{cmd}`

      if $?.exitstatus > 0
        raise "Artifact unpack has been failed: #{cmd}"
      end

      cmd ="rm -f #{artifact_file}"
      `#{cmd}`
      @execute_result = artifact_file
    end

    def changed?
      true
    end

    def changed_from_last_version?
      true
    end

  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
docman-0.0.107 lib/docman/commands/nexus_provider_cmd.rb
docman-0.0.106 lib/docman/commands/nexus_provider_cmd.rb
docman-0.0.105 lib/docman/commands/nexus_provider_cmd.rb
docman-0.0.104 lib/docman/commands/nexus_provider_cmd.rb
docman-0.0.103 lib/docman/commands/nexus_provider_cmd.rb
docman-0.0.102 lib/docman/commands/nexus_provider_cmd.rb
docman-0.0.101 lib/docman/commands/nexus_provider_cmd.rb
docman-0.0.100 lib/docman/commands/nexus_provider_cmd.rb
docman-0.0.99 lib/docman/commands/nexus_provider_cmd.rb
docman-0.0.98 lib/docman/commands/nexus_provider_cmd.rb
docman-0.0.97 lib/docman/commands/nexus_provider_cmd.rb
docman-0.0.96 lib/docman/commands/nexus_provider_cmd.rb
docman-0.0.95 lib/docman/commands/nexus_provider_cmd.rb
docman-0.0.94 lib/docman/commands/nexus_provider_cmd.rb
docman-0.0.93 lib/docman/commands/nexus_provider_cmd.rb
docman-0.0.92 lib/docman/commands/nexus_provider_cmd.rb
docman-0.0.91 lib/docman/commands/nexus_provider_cmd.rb
docman-0.0.90 lib/docman/commands/nexus_provider_cmd.rb
docman-0.0.89 lib/docman/commands/nexus_provider_cmd.rb
docman-0.0.88 lib/docman/commands/nexus_provider_cmd.rb