Class: Docman::NexusProvider

Inherits:
Command
  • Object
show all
Defined in:
lib/docman/commands/nexus_provider_cmd.rb

Instance Attribute Summary

Attributes inherited from Command

#type

Instance Method Summary collapse

Methods inherited from Command

#add_action, #add_actions, #config, create, #describe, #initialize, #perform, #prefix, register_command, #replace_placeholder, #run_actions, #run_with_hooks

Methods included from Logging

#log, logger, #logger, #prefix, #properties_info, #with_logging

Constructor Details

This class inherits a constructor from Docman::Command

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/docman/commands/nexus_provider_cmd.rb', line 51

def changed?
  true
end

#changed_from_last_version?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/docman/commands/nexus_provider_cmd.rb', line 55

def changed_from_last_version?
  true
end

#executeObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/docman/commands/nexus_provider_cmd.rb', line 14

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

#validate_commandObject



6
7
8
9
10
11
12
# File 'lib/docman/commands/nexus_provider_cmd.rb', line 6

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