Permalink
Browse files

allow multiple tokens for different OBS builds

Use a comma separated list of tokens and send several http post requests.

Signed-off-by: Arun Persaud <arun@nubati.net>
  • Loading branch information...
1 parent 90aa7af commit dcb228a22fab8d9889d76244892136f5bd445ee0 @arunpersaud arunpersaud committed with adrianschroeter Feb 18, 2014
Showing with 17 additions and 12 deletions.
  1. +2 −0 docs/obs
  2. +15 −12 lib/services/obs.rb
View
@@ -20,6 +20,8 @@ Install Notes
That means the token can only be used for this package. It also means you do not have
to specify it in github.com. Just using the token is enough.
+ You can also use a comma separated list of tokens to trigger several obs builds.
+
2. Enter your credentials at github.com
- The token which got created (use "osc token" if you lost it)
- optional: Modify the api url, if you do not use the openSUSE Build Service instance.
View
@@ -15,26 +15,29 @@ class Service::Obs < Service::HttpPost
def receive_push
# required
- token = required_config_value('token')
+ token = required_config_value('token').to_s
url = config_value('url')
url = "https://api.opensuse.org:443" if url.blank?
# optional. The token may set the package container already.
project = config_value('project')
package = config_value('package')
- if token.match(/^[A-Za-z0-9+\/=]+$/) == nil
+ # multiple tokens? handle each one individually
+ token.split(",").each do |t|
# token is not base64
- raise_config_error "Invalid token"
+ if t.strip.match(/^[A-Za-z0-9+\/=]+$/) == nil
+ raise_config_error "Invalid token"
+ end
+
+ http.ssl[:verify] = false
+ http.headers['Authorization'] = "Token #{t.strip}"
+
+ url = "#{url}/trigger/runservice"
+ unless project.blank? or package.blank?
+ url << "?project=#{CGI.escape(project)}&package=#{CGI.escape(package)}"
+ end
+ deliver url
end
-
- http.ssl[:verify] = false
- http.headers['Authorization'] = "Token #{token}"
-
- url = "#{url}/trigger/runservice"
- unless project.blank? or package.blank?
- url << "?project=#{CGI.escape(project)}&package=#{CGI.escape(package)}"
- end
- deliver url
end
end

0 comments on commit dcb228a

Please sign in to comment.