Last active
May 4, 2016 18:51
-
-
Save alexandreprates/46fbc7d9454841fb5fdee8e014e98bbb to your computer and use it in GitHub Desktop.
Start Jenkins build on command line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'net/http' | |
| require 'uri' | |
| require 'yaml' | |
| def http_get(url) | |
| url = URI.parse url | |
| response = Net::HTTP.get_response(url) | |
| case response.code | |
| when '201', '302' | |
| puts "Build in progress! ☕ " | |
| else | |
| puts "Ops, something whent wrong :(" | |
| end | |
| end | |
| BUILDLIST = File.join(ENV['HOME'], '.build.yml') | |
| urls = YAML.load_file BUILDLIST | |
| case ARGV | |
| when ['list'] | |
| urls.each do |project, stages| | |
| puts "#{project}\n #{stages.keys.join(', ')}\n\n" | |
| end | |
| exit 0 | |
| when ['edit'] | |
| system "vim #{BUILDLIST}" | |
| end | |
| unless ARGV[1] == 'in' | |
| puts "usage: build [options]\nExamples:\n\tbuild project in stage" | |
| exit(1) | |
| end | |
| project = ARGV[0] | |
| stage = ARGV[2] | |
| url = urls[project] && urls[project][stage] | |
| if url | |
| http_get(url) | |
| else | |
| warn "Can't know nothing about #{project} in #{stage}!" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| curl https://gist.githubusercontent.com/alexandreprates/46fbc7d9454841fb5fdee8e014e98bbb/raw/3a05a2aa657b41196da688106c0742c1df98b570/build > /usr/bin/build && chmod +x /usr/bin/build |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ curl https://gist.githubusercontent.com/alexandreprates/46fbc7d9454841fb5fdee8e014e98bbb/raw/5322f2667de225cebcaca9f132b632ae27d67fad/install.sh | sudo sh