factor-connector-travis 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/factor/connector/travis.rb +80 -0
- metadata +78 -0
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'factor-connector-api'
|
2
|
+
require 'travis'
|
3
|
+
|
4
|
+
Factor::Connector.service 'travis' do
|
5
|
+
|
6
|
+
action 'rebuild' do |params|
|
7
|
+
repo_slug = params['repo']
|
8
|
+
access_token = params['access_token']
|
9
|
+
github_token = params['github_token']
|
10
|
+
use_pro = params['pro']
|
11
|
+
build_number = params['build']
|
12
|
+
|
13
|
+
fail 'Must specify repo (e.g. rails/rails)' unless repo_slug
|
14
|
+
unless access_token || github_token
|
15
|
+
fail 'Must specify access_token or github_token'
|
16
|
+
end
|
17
|
+
|
18
|
+
travis = use_pro ? Travis::Pro : Travis
|
19
|
+
|
20
|
+
product_name = use_pro ? 'Travis Pro' : 'Travis'
|
21
|
+
token_type = access_token ? 'access' : 'Github'
|
22
|
+
|
23
|
+
info "Connecting to #{product_name} with #{token_type} token"
|
24
|
+
begin
|
25
|
+
if access_token
|
26
|
+
travis.access_token = access_token
|
27
|
+
elsif github_token
|
28
|
+
travis.github_auth github_token
|
29
|
+
end
|
30
|
+
user = travis::User.current
|
31
|
+
info "Connected with user #{user.name}"
|
32
|
+
rescue
|
33
|
+
fail 'Token is incorrect'
|
34
|
+
end
|
35
|
+
|
36
|
+
info "Looking up repo `#{repo_slug}`"
|
37
|
+
begin
|
38
|
+
repo = travis::Repository.find(repo_slug)
|
39
|
+
rescue
|
40
|
+
fail "Failed to find the repo '#{repo_slug}'"
|
41
|
+
end
|
42
|
+
|
43
|
+
begin
|
44
|
+
if build_number
|
45
|
+
info "Looking up build #{build_number}"
|
46
|
+
build = repo.build(build_number)
|
47
|
+
else
|
48
|
+
info 'Looking up last build'
|
49
|
+
build = repo.last_build
|
50
|
+
info "Found build ##{build.number}"
|
51
|
+
end
|
52
|
+
rescue
|
53
|
+
fail 'Failed to find the build'
|
54
|
+
end
|
55
|
+
|
56
|
+
info "Restarting build ##{build.number}"
|
57
|
+
begin
|
58
|
+
build.restart
|
59
|
+
rescue
|
60
|
+
fail 'Failed to restart the build'
|
61
|
+
end
|
62
|
+
|
63
|
+
build_info = {
|
64
|
+
repository_id: build.repository_id,
|
65
|
+
commit_id: build.commit_id,
|
66
|
+
number: build.number,
|
67
|
+
pull_request: build.pull_request,
|
68
|
+
pull_request_number: build.pull_request_number,
|
69
|
+
pull_request_title: build.pull_request_title,
|
70
|
+
config: build.config,
|
71
|
+
state: build.state,
|
72
|
+
started_at: build.started_at,
|
73
|
+
finished_at: build.finished_at,
|
74
|
+
duration: build.duration,
|
75
|
+
job_ids: build.job_ids
|
76
|
+
}
|
77
|
+
|
78
|
+
action_callback build_info
|
79
|
+
end
|
80
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: factor-connector-travis
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Maciej Skierkowski
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-09-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: factor-connector-api
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.0.1
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.0.1
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: travis
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - '='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.6.9
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - '='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.6.9
|
46
|
+
description:
|
47
|
+
email:
|
48
|
+
- maciej@factor.io
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- lib/factor/connector/travis.rb
|
54
|
+
homepage: https://factor.io
|
55
|
+
licenses: []
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 1.8.25
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: Travis-CI Factor.io Connector
|
78
|
+
test_files: []
|