Class: Vx::Builder::Script::Artifacts

Inherits:
Struct
  • Object
show all
Includes:
Helper::TraceShCommand
Defined in:
lib/vx/builder/script/artifacts.rb

Constant Summary collapse

FIND =
'find . -type f -path "./%s" | sed "s/^\.\///g"'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper::TraceShCommand

#trace_sh_command

Instance Attribute Details

#appObject

Returns the value of attribute app

Returns:

  • (Object)

    the current value of app



5
6
7
# File 'lib/vx/builder/script/artifacts.rb', line 5

def app
  @app
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vx/builder/script/artifacts.rb', line 11

def call(env)
  rs = app.call env

  if enabled?(env)
    env.after_script << "echo"
    env.source.artifacts.files.map{|a| compile(a) }.each do |artifact|
      find = FIND % artifact
      url = env.task.artifacts_url_prefix
      prefix = env.source.artifacts.prefix
      name = prefix ? "#{prefix}$i" : "$i"
      cmd = %{
        for i in $(#{find}) ; do
          echo "upload artifact #{name}"
          curl -s -S -X PUT -T $i #{url}/#{name} > /dev/null
        done
      }
      env.after_script << cmd
    end
    env.after_script << "echo"
  end

  rs
end