9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/codeclimate_circle_ci_coverage/circle_ci_2.rb', line 9
def download_files
if ENV["CIRCLE_TOKEN"].nil?
puts "You must create a Circle CI Artifacts-API token to use this on Circle CI 2.0"
puts "Please create that, and store the key as CIRCLE_TOKEN"
return []
end
api_url = "https://circleci.com/api/v1.1/project/github/#{ENV['CIRCLE_PROJECT_USERNAME']}/#{ENV['CIRCLE_PROJECT_REPONAME']}/#{ENV['CIRCLE_BUILD_NUM']}/artifacts?circle-token=#{ENV['CIRCLE_TOKEN']}"
artifacts = open(api_url)
paths = matching_urls(JSON.load(artifacts))
if paths.none?
puts "No Results Found. Did you store the artifacts with 'store_artifacts'?"
puts "did you use 'prefix: coverage'?"
return []
end
paths.map do |path|
JSON.load(open("#{path}?circle-token=#{ENV['CIRCLE_TOKEN']}"))
end
end
|