https://github.com/rightpoint/circleci_artifact
Easily fetch CircleCI artifact URLs
https://github.com/rightpoint/circleci_artifact
Last synced: about 1 year ago
JSON representation
Easily fetch CircleCI artifact URLs
- Host: GitHub
- URL: https://github.com/rightpoint/circleci_artifact
- Owner: Rightpoint
- License: mit
- Created: 2018-04-16T22:48:08.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-19T20:59:33.000Z (about 8 years ago)
- Last Synced: 2024-09-17T11:29:15.780Z (almost 2 years ago)
- Language: Ruby
- Size: 20.5 KB
- Stars: 0
- Watchers: 9
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# circleci_artifact
[](https://circleci.com/gh/Raizlabs/circleci_artifact)
This library is designed to make fetching the URLs for [CircleCI build artifacts](https://circleci.com/docs/2.0/artifacts/#downloading-all-artifacts-for-a-build-on-circleci) quick and easy. Unfortunately CircleCI makes it difficult to get the URLs for your build artifacts without hitting their API, so it's not straightforward to include links to your artifacts as part of the CI process.
This gem was built to be used in combination with tools like [Fastlane](https://github.com/fastlane/fastlane) and [Danger](https://github.com/danger/danger). The functionality is very limited at this point, and just makes it easier to grab single artifacts whose URL match a substring.
## Getting Started
* Create a new CircleCI account for your CI bot user.
* Create a CircleCI API token in the application by going to [User Settings > Personal API Tokens](https://circleci.com/account/api).
* Create a new token called `CIRCLE_API_TOKEN`.
* Add `CIRCLE_API_TOKEN` to the CircleCI build environment for the target repo.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'circleci_artifact'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install circleci_artifact
## Usage
```ruby
require 'circleci_artifact'
# Set this yourself using the steps in "Getting Started"
token = ENV['CIRCLE_API_TOKEN']
# These are already in the Circle environment
# https://circleci.com/docs/2.0/env-vars/#build-specific-environment-variables
username = ENV['CIRCLE_PROJECT_USERNAME']
reponame = ENV['CIRCLE_PROJECT_REPONAME']
build = ENV['CIRCLE_BUILD_NUM']
fetcher = CircleciArtifact::Fetcher.new(token: token, username: username, reponame: reponame, build: build)
xcov = CircleciArtifact::Query.new(url_substring: 'xcov/index.html')
slather = CircleciArtifact::Query.new(url_substring: 'slather/index.html')
screenshots = CircleciArtifact::Query.new(url_substring: 'screenshots/index.html')
queries = [xcov, slather, screenshots]
results = fetcher.fetch_queries(queries)
xcov_url = results.url_for_query(xcov)
slather_url = results.url_for_query(slather)
screenshots_url = results.url_for_query(screenshots)
puts "xcov_url #{xcov_url}"
puts "slather_url #{slather_url}"
puts "screenshots_url #{screenshots_url}"
```
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/Raizlabs/circleci_artifact. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
## Code of Conduct
Everyone interacting in the CircleciArtifact project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Raizlabs/circleci_artifact/blob/master/CODE_OF_CONDUCT.md).