|
4 | 4 | require 'rake/clean'
|
5 | 5 | require 'json'
|
6 | 6 | require 'net/http'
|
| 7 | +require 'rest-client' |
7 | 8 | require 'travis-build-tools'
|
8 | 9 |
|
9 | 10 | #Constants
|
|
37 | 38 | task :clobber => [:clean]
|
38 | 39 | CLOBBER.include(TARGET_DIR, AMPS_DIR)
|
39 | 40 |
|
40 |
| -ATLASSIAN_TOOLS = File.join(PWD, 'atlassian-tools') |
41 |
| -directory ATLASSIAN_TOOLS |
42 |
| -task :setup => [ATLASSIAN_TOOLS] do |
| 41 | +ATLASSIAN_TOOLS_DIR = File.join(PWD, 'atlassian-tools') |
| 42 | +file ATLASSIAN_TOOLS_DIR do |
| 43 | + FileUtils.mkdir_p(ATLASSIAN_TOOLS_DIR) |
43 | 44 | remote_location = 'https://marketplace.atlassian.com/download/plugins/atlassian-plugin-sdk-tgz'
|
44 |
| - local_path = File.join(ATLASSIAN_TOOLS, 'atlassian.tgz') |
45 |
| - uri = URI(remote_location) |
46 |
| - Net::HTTP.start(uri.host, uri.port) do |http| |
47 |
| - request = Net::HTTP::Get.new(uri.request_uri) |
48 |
| - http.request(request) do |response| |
49 |
| - fileTotalSize = response["content-length"] |
50 |
| - open(local_path, 'wb') do |streamFile| |
51 |
| - response.read_body do |chunk| |
52 |
| - streamFile.write chunk |
53 |
| - print ((File.size(streamFile).to_f / fileTotalSize.to_f) * 100).round(2).to_s + " % \r" |
54 |
| - end |
55 |
| - end |
56 |
| - end |
| 45 | + atlassian_tools = File.join(ATLASSIAN_TOOLS_DIR, 'atlassian.tgz') |
| 46 | + download_file(atlassian_tools, remote_location) |
| 47 | + Dir.chdir(ATLASSIAN_TOOLS_DIR) do |
| 48 | + puts %x[tar -xzvf #{File.basename(atlassian_tools)}] |
| 49 | + end |
| 50 | +end |
| 51 | +task :setup => [ATLASSIAN_TOOLS_DIR] |
| 52 | + |
| 53 | +def download_file(local_path, remote_location) |
| 54 | + url = URI::encode(remote_location) |
| 55 | + begin |
| 56 | + response = RestClient.get(url) |
| 57 | + |
| 58 | + FileUtils.mkdir_p(File.dirname(local_path)) |
| 59 | + File.open(local_path, 'wb'){|file| file.write(response.body)} |
| 60 | + rescue Exception => exception |
| 61 | + puts "Failed to download #{url}:" |
| 62 | + raise |
57 | 63 | end
|
58 | 64 | end
|
59 | 65 |
|
60 | 66 | task :build do
|
61 |
| - |
| 67 | + script = Dir[File.join(ATLASSIAN_TOOLS_DIR, "**", 'atlas-package')].first |
| 68 | + puts %x[#{script}] |
62 | 69 | end
|
63 | 70 |
|
64 | 71 | publish_git_tag :publish_git_tag do |t, args|
|
|
0 commit comments